December 4th, 2004, 04:35 PM
|
#1 (permalink)
| | Member
Join Date: Oct 2003
Posts: 255
|
Hi,
( VB.NET)
Creo I asked this before but I am having a heck of a time trying to do this. I have an application where it loads form1. I am trying to intially hide form1 and show form2. However no matter where i put the form1.hide() or the form 1.visible=false it still shows form1.
I guess if someone can list when a page loads what subs does it launch? init?, then load? the finalize etc.
Where would I have to put the hide(). I even tried to put it in the form2_load and it still shows form1.
Any ideas guys???
Thank you |
| |
December 4th, 2004, 04:38 PM
|
#2 (permalink)
| | Kawaru wa yo!
Join Date: Oct 2001 Location: Kingsford, MI
Posts: 16,137
|
Why not just make form1 form2 and vice versa? Does the current form1 NEED to load first for some reason? |
| |
December 4th, 2004, 04:56 PM
|
#3 (permalink)
| | Member
Join Date: Oct 2003
Posts: 255
|
yeah form1 is gonna be my main menu and im gonna keep it loaded at all times. form 2 will be my splash screen. Form 1 needs to be atleast in memory at all times otherwise the application will close. If i use a sub main it loads the 2 forms and shows form 1 then exits the application. |
| |
December 4th, 2004, 05:00 PM
|
#4 (permalink)
| | Perfetc Member
Join Date: Jan 2003 Location: Maryland Suburbia
Posts: 4,327
|
why not do Application.Run() or Application.Run(splashscreenform) - which will start and then load that form to begin with.
That'll keep the program thread open with or without a form open
Then you can show/hide accordingly. |
| |
December 4th, 2004, 05:32 PM
|
#5 (permalink)
| | Member
Join Date: Oct 2003
Posts: 255
|
alright i've never used application.run() would i need to create another .exe with just the splash creen. It would be alot bettter to keep 1 .exe with multiple forms |
| |
December 5th, 2004, 11:54 AM
|
#6 (permalink)
| | Member
Join Date: Oct 2003
Posts: 255
|
if anyone wants to know.... put it in the activated sub
Private Sub Form1_Activated(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Activated
Dim f As New Form2
f.Show()
Me.Hide()
End Sub |
| |
December 5th, 2004, 05:51 PM
|
#7 (permalink)
| | Member
Join Date: Oct 2003
Posts: 255
|
I really hate how Microsoft used Forms in .net
ok I have the main form...it gets hidden as soon as the program loads under the activated property. Then the splash form loads with a timer and progress bar...after the progress bar =100 then i say close the splash screen and load the main menu screen. However it creates an endless loop. I believe it is because i have the code in main menu form to load the splash screen, so when i go from splash to .show the main menu it loads the main menu form again which has the code to reopen thesplash screen. I tested it and it doesnt seem like thats the case. here is my code. Any help would be great...thanks guys.
----------------------------------------------------------------------------------------------
Main Form Code
Private Sub frmMain_Activated(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Activated
Dim Splash As New frmSplash()
Splash.Show()
Me.Hide()
End Sub
----------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------
Splash Code
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Do While ProgressBar1.Value <> 100
ProgressBar1.Value = ProgressBar1.Value + 1
Loop
Timer1.Enabled = False
Dim Main As New frmMain()
Main.show
End Sub
Any Idea's |
| |
December 5th, 2004, 05:55 PM
|
#8 (permalink)
| | Perfetc Member
Join Date: Jan 2003 Location: Maryland Suburbia
Posts: 4,327
|
I would avoid using stuff like "<>"
Try just a straight "<"
It could be that its ticking to 101 before the timer actually get disabled.
I'm not really sure how VB handles threads.... and if its half as bad as Java Threads you dont want to rely on really specific timing for operations/loops. |
| |
December 5th, 2004, 06:31 PM
|
#9 (permalink)
| | Member
Join Date: Oct 2003
Posts: 255
|
na thats not the problem. I just tried it and it still did the same thing. Any other guesses? |
| |
December 5th, 2004, 06:39 PM
|
#10 (permalink)
| | Perfetc Member
Join Date: Jan 2003 Location: Maryland Suburbia
Posts: 4,327
|
Hmm, well if you changed it into a For/Next loop theres no way it would end up in an infinite loop, so you'd at least know if its a problem in that or not (which it prolly isnt though).
I'm really not al lthat familiar with .net languages and how it handles classes/objects, but why are you instantiating a new "main form" object.
Doesnt this object already exist?
In which case you should only need to pass reference to it. |
| | |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | | |
Posting Rules
| You may post new threads You may post replies You may not post attachments You may not edit your posts HTML code is Off | | | | Most Active Discussions | | | | | Recent Discussions  | | | | | |