Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Wait for form to be unloaded

Status
Not open for further replies.

Jouster

Programmer
Dec 4, 2000
82
US
Hello,

I'm working on a program that loads and unloads a few different forms. What I want to do is load a form and the user will perform some functions then unload the form and load the next one. The problem I'm seeing is I load the first form and then the program keeps executing and loads the next form(s). How can I make it wait until the first form is finished? The forms are being controlled from a module in my app.

The program is running on a Win98 machine.

Thanks for any input,
J
 
When you load the form do this...

Form1.Show vbModal
Form2.Show vbModal
Form3.Show vbModal

This will make each form complete before the next is displayed...

Casper

There is room for all of gods creatures, "Right Beside the Mashed Potatoes".
 
You might try posting some of your code that shows where and how your loading the forms. Are you loading all forms from one main form or are you loading forms from each previous form.
 

Thanks Casper. I tried the vbmodal but still had the same problem.

Here's a little more detail. I have a main form with options 1, 2, 3, 4 ect. You can select any option and the corresponding form will be loaded and all is well.

Next I have an option to go through all the forms one at a time. The main form calls out a sub in a module that loads the forms one after the other.

Here is part of the code:

Module code: Runs all the forms.
'Run complete suite of tests
Public Sub complete()

If test1() = False Then
Beep
MsgBox "Display Test Failed"
End If

If test2() = False Then
Beep
MsgBox "Menu Button Test Failed"
End If

If UUTTouch < 3 Then 'do we have a touchscreen?
If test3() = False Then
Beep
MsgBox "Touchscreen Test Failed"
End If
End If

If UUTModel = "5012" Or UUTModel = "5015" Then
If test4() = False Then
Beep
MsgBox "Rear Mouse Test Failed"
End If

If test5() = False Then
Beep
MsgBox "Front Mouse Test Failed"
End If

If test6() = False Then
Beep
MsgBox "USB Test Failed"
End If

If test7() = False Then
Beep
MsgBox "Keypad/Keyboard Test Failed"
End If
End If

End Sub

The individual funtions will load the correct form for the user.

Hope this is more informative.

J

 
Are you saying that the message boxes are popping up to quickly? Like you want one message box let the user click OK, then the next Message box?

Casper

There is room for all of gods creatures, "Right Beside the Mashed Potatoes".
 
If it is the Message Box forms you are talking about? Though a Message Box is more of a control than a form, though a form is still a control but more of a container... Sorry I'm confusing myself....

But if that's what you want to do, you have to change your code to this... In Blue
Code:
Module code: Runs all the forms.
'Run complete suite of tests
Public Sub complete()
    [COLOR=blue][b]Dim lRet as Long[/b][/color]    
    If test1() = False Then
        Beep
        [COLOR=blue][b]lRet = MsgBox ("Display Test Failed", vbOkOnly)[/b][/color]
    End If
    
    If test2() = False Then
        Beep
        [COLOR=blue][b]lRet = MsgBox("Menu Button Test Failed", vbOkOnly)[/b][/color]
    End If
     
    If UUTTouch < 3 Then 'do we have a touchscreen?
        If test3() = False Then
            Beep
            [COLOR=blue][b]lRet = MsgBox("Touchscreen Test Failed", vbOkOnly)[/b][/color]
        End If
    End If
    
    If UUTModel = "5012" Or UUTModel = "5015" Then
        If test4() = False Then
            Beep
            [COLOR=blue][b]lRet = MsgBox("Rear Mouse Test Failed", vbOkOnly)[/b][/color]
        End If
        
        If test5() = False Then
            Beep
            [COLOR=blue][b]lRet = MsgBox("Front Mouse Test Failed", vbOkOnly)[/b][/color]
        End If
        
        If test6() = False Then
            Beep
            [COLOR=blue][b]lRet = MsgBox("USB Test Failed", vbOkOnly)[/b][/color]
        End If
        
        If test7() = False Then
            Beep
            [COLOR=blue][b]lRet = MsgBox("Keypad/Keyboard Test Failed", vbOkOnly)[/b][/color]
        End If
    End If
    
End Sub

Casper

There is room for all of gods creatures, "Right Beside the Mashed Potatoes".
 
Thanks again Casper but its not the message boxes I'm having problems with its the forms that the test functions load and unload.

In function test1() I have a form that loads to perform the test then unload. then test2() should run next and ect.

The problem is its running test1 then test2 ect with out waiting for test1 to end. Hope I'm explaing well enough. I might have to try another way around this.

Thanks again.
J
 
Actually If you could post the Test1() code... Then I may be able to see a little better.

Casper

There is room for all of gods creatures, "Right Beside the Mashed Potatoes".
 
hmm..Jouster what about something like this:

'wait for the form to be unloaded

Do
DoEvents
Loop Until Form1.visible = true

'form was unloaded
'for example, load form2 now
form2.show





---------------------------------
LendPoint Software
 
Casper,

The test1 code:

public function test1()
load frmMouse
frmMouse.show
end function

Not too much to it.


Thanks Lendpoint, I wll try that as soon as I reload Win98. Visual Studio crashed and now I can't boot to the desktop.

J
 
Well in this case...

frmMouse.show vbModal

should wait until that one is done... I don't see why it wouldn't wait?


Casper

There is room for all of gods creatures, "Right Beside the Mashed Potatoes".
 
As casperTFG stated earlier
Form1.Show vbModal

try this

Code:
'dimension the object (of type frmMouse)
dim f as frmMouse

'Create an instance of frmMouse
set f = new frmMouse

'Show it
'the vbModal argument stops processing in 'this function until the form is unloaded

f.show vbmodal

'tidy up by releasing object
set f = nothing

You may need to ensure that the frmMouse has a unload me statement after you complete testing the mouse.

Take Care

Matt
If at first you don't succeed, skydiving is not for you.
 
Not sure that would do anything different by making a pointer to it... But one more comment... What a great signature MK... It's going on my whiteboard right now..

Casper

There is room for all of gods creatures, "Right Beside the Mashed Potatoes".
 
CasperTFG said:
Not sure that would do anything different by making a pointer to it...

Quite right, there is no functional difference.

In my opinion doing the explicit creation like that is good practice as it makes the object lifetime & scope easier to understand.

It seems inconsistent to me that you can instance a form in that single stage, but not a class object.

CasperTFG said:
But one more comment... What a great signature MK... It's going on my whiteboard right now..
[wink]

Take Care

Matt
If at first you don't succeed, skydiving is not for you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top