passing control from one form to another
Problem I'm having is that i can pass control from one form to another when the user presses a button like:
Private Sub Button2_Click1(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click
Me.Hide()
Form3.Visible = True
Form3.Focus()
End Sub
...but, what if I want to pass control based on a timeout.....the following doesn't work (where sleep is a simple loop to pass time):
Private Sub Form7_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.Sleep(1000000)
Form1.Visible = True
Form1.Focus()
End Sub
any ideas?? (what I mean by doesn't work is that the displayed form doesn't change to the new form)
thanks.
Re: passing control from one form to another
try calling the show() method of the form you want to display.
Re: passing control from one form to another
nope....that still leaves the old form up there. The only way that (so far) I can get the new form to show is by using "me.close" which closes the old form and leaves the new form up there. The problem with that is that all the code in Form_load is executed before the loading form is visible.....argh.....so if me.close is in Form_load.....the form to load upon time-out is immediately shown and THEN the delay occurs instead of the other way around. It's like I need a way to execute code that is NOT in the Form_load routine.....so that the form can load...and then my code will execute.
kgb
Re: passing control from one form to another
Quote:
Originally Posted by cageybee
The problem with that is that all the code in Form_load is executed before the loading form is visible.....argh....
kgb
not if you put
Code:
me.visible = true
application.doevents()
in the form load before any other code.
Re: passing control from one form to another
this is crazy....when I do this from within Private Sub Form7_Load Form:
Form1.Visible = True
Form1.Focus()
Form1.Show()
Application.DoEvents()
MsgBox("test")
it "shows" form1, but then after I hit <enter> it reshows form7.....
form7 won't let go unless I hit the button and execute:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Me.Hide()
Form1.Visible = True
Form1.Focus()
End Sub
what is so special about code executed in the button_click????