[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 230
  • Last Modified:

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.
0
Gordon_Atherley
Asked:
Gordon_Atherley
  • 2
1 Solution
 
MrPanCommented:
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.

0
 
MrPanCommented:
change Dim frmMod as frmMOdular

to be

Dim frmMod as New frmMOdular
0
 
mladenoviczCommented:
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
0
 
Gordon_AtherleyAuthor Commented:
Thank you for the prompt and valuable response, appreciated

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

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now