|
-
Aug 23rd, 2000, 10:18 AM
#1
Thread Starter
Lively Member
What is the best way to pass a string from one form to another? I have multiple instances of a main form which allows a user to select multiple users for a query.
For layout purposes... Rather than putting the user listbox on the main form, I have a Select User (frmSelUser) form opened with the user listbox.
I would like to pass the calling formname to frmSelUser so that I know which form to pass the string of selected users back to... since there can be multiple instances of the form opened at one point in time.
Thanks!
Kevin
VB6 w/SP4
-
Aug 23rd, 2000, 11:20 AM
#2
Fanatic Member
If the form has a module level variable, then this can be assigned from another form, provided that it is loaded,
See the following example:
Create a new project,
Add two forms, with a command button on each and a bas module,
In the declarations of Form1 paste the following:
Option Explicit
Private Sub Command1_Click()
ReDim Preserve NewFrm(intNo)
Set NewFrm(intNo) = New Form2
Load NewFrm(intNo)
NewFrm(intNo).Caption = "Form" & intNo
NewFrm(intNo).Myvar = "Form" & intNo
NewFrm(intNo).Show
intNo = intNo + 1
End Sub
In the declarations of Form2 paste the following:
Option Explicit
Public Myvar As String
Private Sub Command1_Click()
MsgBox Myvar
End Sub
In the declarations of Module1 paste the following:
Option Explicit
Public NewFrm() As Form
Public intNo As Integer
Press F5 when the command1 is clicked on Form1 a new form is drawn, and its Myvar is assigned a new value,
Click the Command1 on the new forms will display a message from that variable.
Hope this helps................ ;-)
-
Aug 23rd, 2000, 11:44 AM
#3
Thread Starter
Lively Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|