Create a Form with the Vb code

Posted on 2003-02-26
Medium Priority
Last Modified: 2010-05-01
I have a form1 in which i have created a button , when u click the button in form1 it should generate a form2 getting few parameter from form1 and do few claculations .Apart from these the form2 also has two buttons ,few standard data and decorations.I need to create this form by writing Vb script .Since i've just started vb can anyone help me to proceed with this issue.
Thanks in Advance
Question by:vb_7
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Expert Comment

ID: 8023784
you can create new forms by using "new" keyword. as follows:

dim frm2
set frm2=new form1
'you can use tag to distinguish form2 from form1 because the outlook and behavior of form2 is exactly same as form1

'show the newly created form

then in any sub, respond according to the tag value, e.g:

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
if me.tag="form2" then
  'execute code for form2
  'execute code for form1
end if

good luck!

Expert Comment

ID: 8023834
you cited you need to use VBSCRIPT... but i assume you just mean VB code...

' ************ in form1 *****************
Private Sub Command1_Click

  'we will write in Caption of Form2 the sum of the passed parameters

  Dim frm as new Form2
  Dim i as Integer, j as Integer

  frm.Show vbModal

  set frm = nothing
End Sub

'******************in form2 **************

Public Sub A_Setup(Num1 as Integer, Num2 as Integer)

  Me.Caption = Cstr(Num1 + Num2)

end Sub

Expert Comment

ID: 8024566

In Vb You Want To Do Some Calcualtions in Form2 also, then There Is No Way Using the Above Comments. So In Design Time Itself You Just add One More Form. By default its Name is Form2.

Write Function in Form2 as Follows,
Function cal(i As Integer)
    MsgBox i
End Function

assume u have coomand1 in Form1

public sub command1_click()
   call cal(10)
end sub

I Hope This will be HelpFul

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.


Expert Comment

ID: 8029075
So you want to pass variables between forms...

I tried earlnoli's code ,.. couldn't get it to work...

the only way I've been able to do it is by loading
controls within form one with the data you want to preserve and then loading the new form modally (I think)  
and getting the values from the still open form.

form1, form2




Expert Comment

ID: 8901104
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
Experts: Post your closing recommendations!  Who deserves points here?
LVL 49

Expert Comment

ID: 8972916
vb_7, an EE Moderator will handle this for you.
Moderator, my recommended disposition is:

    Save as PAQ -- No Refund.

DanRollins -- EE database cleanup volunteer

Accepted Solution

Computer101 earned 0 total points
ID: 9668015
PAQed - no points refunded (of 50)

E-E Admin

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question