?
Solved

Different forms within a project

Posted on 2000-03-08
7
Medium Priority
?
163 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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 400 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

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…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
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…
Suggested Courses

840 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