?
Solved

Avoiding Public global variables when getting data from modular form

Posted on 2004-08-17
4
Medium Priority
?
228 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 2

Expert Comment

by:MrPan
ID: 11821294
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 500 total points
ID: 11821329
change Dim frmMod as frmMOdular

to be

Dim frmMod as New frmMOdular
0
 
LVL 8

Expert Comment

by:mladenovicz
ID: 11821435
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
ID: 11821443
Thank you for the prompt and valuable response, appreciated

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

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses
Course of the Month11 days, 12 hours left to enroll

752 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