Solved

Different forms within a project

Posted on 2000-03-08
7
153 Views
Last Modified: 2010-05-02
I am currently writing a client server application using VB 6.0 and RPG 4 (AS\400).  

I have created a project in VB and have several forms within the project.  Each form is a seperate program.  For example the main form is a list box loaded with records. When the left mouse button is clicked on a record a pop up list of options is displayed.  When an option is selected i pass information from that record into a new form and display the new form.  When the new form is loaded i want processing to remain in that form until the user exits.  At the moment the form loads but processing continues in the calling form.  

Is there a on exit resume next type command?  

Can anyone help??
0
Comment
Question by:CRICE
  • 4
  • 3
7 Comments
 
LVL 2

Expert Comment

by:p_biggelaar
ID: 2596350
If you don't mind that the user cannot do anything else then work with that form untill he's ready, call the form like this:

YourForm.Show vbModal

This means the form will be shown as modal, and code in the calling form will only continue executing after you unloaded the second form
0
 
LVL 2

Expert Comment

by:p_biggelaar
ID: 2596359
Simple example:

Create new project, add two forms (Form1, Form2)
On the first form add one commandbutton (command1), on the second add two commandbuttons (command1, command2)

Add this code to Form1:

Private Sub Command1_Click()
    Form2.Show vbModal
    MsgBox "Back to Form1"
End Sub

Add this code to Form2:

Private Sub Command1_Click()
MsgBox "hallo"
End Sub

Private Sub Command2_Click()
Unload Me
End Sub

Good luck...
0
 

Author Comment

by:CRICE
ID: 2596500
Thanks.. that would work for me, as this is exactly what i am trying to do.

The only problem is that i need to pass a varible to the form load routine.  But because it is a private sub, it will not allow this.  I have tried making the varible public, static etc.. but the varible becomes blanks as soon as the form load routine is accessed.
I built an initial sub routine around the form load, but if i show the form in the initial sub routine and use the vbmodal function the form displays but the screen freezes!!

Any ideas?
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Author Comment

by:CRICE
ID: 2596509
Thanks.. that would work for me, as this is exactly what i am trying to do.

The only problem is that i need to pass a varible to the form load routine.  But because it is a private sub, it will not allow this.  I have tried making the varible public, static etc.. but the varible becomes blanks as soon as the form load routine is accessed.
I built an initial sub routine around the form load, but if i show the form in the initial sub routine and use the vbmodal function the form displays but the screen freezes!!

Any ideas?
0
 
LVL 2

Accepted Solution

by:
p_biggelaar earned 100 total points
ID: 2596632
You could declare a public variable on form1 and access this from form2, like this:

Code in Form1:

Public ThisIsTheRequiredVariable As String

Private Sub Command1_Click()
    ThisIsTheRequiredVariable = "Let's see whether it works!"
    Form2.Show vbModal
    MsgBox "Back to Form1"
End Sub

Code in Form2:

Private Sub Command1_Click()
MsgBox "hallo"
End Sub

Private Sub Command2_Click()
Unload Me
End Sub

Private Sub Form_Load()
Dim ThisIsWhereItGoes As String

    ThisIsWhereItGoes = Form1.ThisIsTheRequiredVariable
   
    MsgBox ThisIsWhereItGoes
End Sub

0
 

Author Comment

by:CRICE
ID: 2596719
Thanks for that... you deserve the points.  As i have not had much experience in VB and i don't get much support from my managers, a web site like this is a god send.  My total VB training has consisted of a book on how to program VB 6.0 in 21 days!!  From this i am suppose to write a client server application using VB and RPG!

Anyway thanks for your time and your help.

Chris
0
 
LVL 2

Expert Comment

by:p_biggelaar
ID: 2598241
Well, good luck and if you've got any questions, you know what to do...

PS: that really is very little training for what you're supposed to do.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

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…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…
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…

747 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

16 Experts available now in Live!

Get 1:1 Help Now