Link to home
Start Free TrialLog in
Avatar of Gordon_Atherley
Gordon_Atherley

asked on

Avoiding Public global variables when getting data from modular form

Suggestions, please:

In a VB6 app, I'm using a modular form to gather user input for processing by the parent from.

I use public global variables to carry the data from the modular form to its parent. (For reasons nothing to do with the question, globals are more useful in the particular situation than module-level variables.)

Is there a better alternative to global or vmodule-level variables to capture the data from the modular form and pass it to the parent form, pelase?

Thanks in anticipation.
Avatar of MrPan
MrPan

There are a couple of ways.

I assume that you are using form2.show 1

You could replace it with

Dim frmMod as frmMOdular

frmMod.Show 1

data= frmmode.txtboxdata

unload frmMode.


You will have to change the close button on the modular form to hide the form instead of closing.

ASKER CERTIFIED SOLUTION
Avatar of MrPan
MrPan

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
First form (not modal)

Private Sub Command1_Click()
    Dim a As String
    Dim b As String
    Call Form2.ShowModalForm(a, b)
   
    MsgBox a & " " & b
End Sub

Second form (modal)

Public Function ShowModalForm(Var1 As String, Var2 As String)
    Me.Show vbModal
   
    Var1 = Text1.Text
    Var2 = Text2.Text
End Function
Avatar of Gordon_Atherley

ASKER

Thank you for the prompt and valuable response, appreciated

The EE respose time is getting into the nanosecond domain, great work!