|
-
Jul 28th, 2008, 02:09 PM
#1
Thread Starter
Lively Member
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.
-
Jul 28th, 2008, 02:18 PM
#2
Re: passing control from one form to another
try calling the show() method of the form you want to display.
-
Jul 28th, 2008, 02:25 PM
#3
Thread Starter
Lively Member
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
Last edited by cageybee; Jul 28th, 2008 at 02:28 PM.
-
Jul 28th, 2008, 02:42 PM
#4
Re: passing control from one form to another
 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.
-
Jul 28th, 2008, 03:44 PM
#5
Thread Starter
Lively Member
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????
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|