Solved

Different forms within a project

Posted on 2000-03-08
7
158 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
[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
  • 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
Industry Leaders: 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 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

Independent Software Vendors: 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!

Question has a verified solution.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

740 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