Specify formName.fieldName.data
WaltP
Posting Sage w/ dash of thyme
10,507 posts since May 2006
Reputation Points: 3,348
Solved Threads: 944
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 .
Comatose
Taboo Programmer
2,910 posts since Dec 2004
Reputation Points: 361
Solved Threads: 215
stan yost there is a simple way
lets say you want to pass the text feild of text1
1- declare a public variable in the general part of the form like this
public varaiableName as String
2- in the form_load() write
variableName=text1.text
3- you can access this variable from any other form using the form name
lets say you have form2 and you want to pass text1.text which is in form1 to form2 which has a text feild (text2)
you can do that like this:-
text2.text=form1.variableName
- Regarding calling methods You have first to decalre it as public intead of private sub ---> public sub
and u can do the same thing using the form name to call the function
form1.functionName()
I hope this helps
vbmenu_register("postmenu_246662", true);
lover99509, is this easier than using form1.text1.text as already recommended?
WaltP
Posting Sage w/ dash of thyme
10,507 posts since May 2006
Reputation Points: 3,348
Solved Threads: 944
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....
Comatose
Taboo Programmer
2,910 posts since Dec 2004
Reputation Points: 361
Solved Threads: 215
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.
Comatose
Taboo Programmer
2,910 posts since Dec 2004
Reputation Points: 361
Solved Threads: 215
Hi
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
frmsummary.Show
End Sub
Thanks for your help in advance
HB25
HB25
Junior Poster in Training
74 posts since Dec 2007
Reputation Points: 10
Solved Threads: 0