Solved

Avoiding Public global variables when getting data from modular form

Posted on 2004-08-17
4
215 Views
Last Modified: 2010-05-02
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
Comment
Question by:Gordon_Atherley
  • 2
4 Comments
 
LVL 2

Expert Comment

by:MrPan
Comment Utility
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
 
LVL 2

Accepted Solution

by:
MrPan earned 125 total points
Comment Utility
change Dim frmMod as frmMOdular

to be

Dim frmMod as New frmMOdular
0
 
LVL 8

Expert Comment

by:mladenovicz
Comment Utility
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
 

Author Comment

by:Gordon_Atherley
Comment Utility
Thank you for the prompt and valuable response, appreciated

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

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now