WaltP is correct. You can also call functions, events and methods this way too. For example, if you have a button on form2, and you want to "click" it from a button on form1, you can do something like form2.command1 = true .
lover's method is accurate, and will work.... however, it's not good programming style. As Waltp Mentioned, it's easier first off, to reference the object hierarchy, and beyond that, why would you want to use memory space (a variable) to contain information that's ALREADY stored somewhere? That will slow down the program (more processing, and memory usage) and make code a bit more difficult to read....
I'm working on something like this and I have the following situation:
I guiding users through a wizard process to select or create various ID's. These ID's are set at the end of the proess when closing the form.
So where I need the ID I start a form in Dialog mode and on closing the new form I set a Public variable in a separate module to the value of this ID.
Within the wizard process I need to do this 2 or three times.
When the dialog form closes the originating form picks up the ID and works with that.
As it now appears the value is not passed between the forms. I cannot refer to the form's variables because at the time I need to pick up the alue the form is already closed.
Using watches I could determine that withn the context of each form the variable doesnot appear to be set.
I refer in the entire project to this variable as GlobalFunctions.SelectedID and in the module GlobalFunction it has been declared as:
Public SelectedID As Long
Unfortunately, the selection process is calledfrom different forms so I cannot define a button that go's back to the originating form that will close the selection form.
I might not understand you completely, but if you are asking what I think you are asking, setting a global variable should work among all forms. I just want to make sure that you are using VB6, and not VB.Net or VB express..... Because I don't believe VB6 has a GlobalFunctions Object.
I am working on a payroll program which have 3 forms.
First form has three text box (First name, Surname, Total Hour) and one command button Calculate.
After the user put the info he/she will click calculate button and this will show the second form which display the (firstname, surname, Gross salary, netwage).
I do have another form called frmsummary this form should hold detail of up to 10 person, currently using the code bellow in form two when user click copy info command button on the second form I could only copy 1 person info to form 3. I don’t know what to do any help to get 10 people info coped?
Private Sub cmdcd_Click()
frmsummary.lblfname0 = frmWage.lblfirstname.Caption
frmsummary.lblsname0 = frmWage.lbllastname.Caption
frmsummary.lblgsalary = frmWage.lblGrossSalary.Caption
frmsummary.lblnwage = frmWage.lblNetWage.Caption
it's easier first off, to reference the object hierarchy ,and beyond that, why would you want to use memory space (a variable) to contain information that's ALREADY stored somewhere? That will slow down the program (more processing, and memory usage) and make code a bit more difficult to read....
That's simply not the case. Declaring objects as variables saves Visual basic from having to go through the same code again. Once VB has it declared as a variable, it saves processing time.
Well, I doubt this will get answered since it was so many years ago, but I'll ask anyways. I passed this data TextBox1.Text to my form two text box Old_Name_Display using stanyost's third method, inserting Old_Name_Display = Browser.TextBox1.Text into my Old_Name_Display_Change public sub.
What my program does is after I select a browsed file, it displays in TextBox1.Text. The user then selects "Rename this Project" and form 2 opens. What it SHOULD do is have the text from form1 displayed in my Old_Name_Display text box. What it's ACTUALLY doing is waiting until I type a character before it inputs that data.