Solved

Different forms within a project

Posted on 2000-03-08
7
155 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Replace Formatted Numbers with text 9 61
VBA saving file message display 5 56
Macro: print each sheet to pdf using ExportAsFixedFormat 11 41
Advice in Xamarin 21 57
Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
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…

867 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

17 Experts available now in Live!

Get 1:1 Help Now