|
-
Mar 23rd, 2004, 12:22 AM
#1
Thread Starter
Junior Member
Show/Hide a form in form_load (Resolved)
I have two forms - frmmain, and form1
Under frmmain, I'm using a If/Then/Else statement checking a variable value.
Frmmain is the startup form.
VB Code:
Dim form1 as new form1
If Val = "1" Then
'do nothing
Else
form1.visible = True
frmmain.visible = False
End If
form1 will always show, but frmmain won't hide. I've tested this using just one form and just putting me.visible = false. I've tried me.hide, I've tried putting the code behind a timer and enabling the timer from form_load, I've tried calling a new sub from form_load, but NOTHING I do seems to work.
Does anyone know what I'm doing wrong?
Last edited by DestructoX; Mar 23rd, 2004 at 01:33 AM.
Logic is a systematic way of coming to the wrong conclusion with confidence.
-
Mar 23rd, 2004, 01:12 AM
#2
Yeah you are trying to hide a form in the load event. You should check your condition without loading the form and then only load it if it will show.
-
Mar 23rd, 2004, 01:16 AM
#3
Thread Starter
Junior Member
The only way I know of doing that is by using Sub Main, but I'm not really familiar with it.
Logic is a systematic way of coming to the wrong conclusion with confidence.
-
Mar 23rd, 2004, 01:25 AM
#4
Why does the form need to be used? What is it you are trying to do? If you ask more specific questions we can help more. To use Sub Main (this may or may not be the best way depending on what you are trying to do) you change the startup in the project properties to Sub Main. Then make a Sub Main method either in a class, module, or the form.
VB Code:
Public Class Startup
Public Sub Main()
'do check here
If Check=True Then
Application.Run(New frmMain)
Else
'do something else
Application.Run(New frmAlternate)
End If
End Sub
End If
-
Mar 23rd, 2004, 01:28 AM
#5
Thread Starter
Junior Member
I've got frmmain and form1
Form1 is basically a wizard to configure some settings.
When the program loads, it uses GetSetting to check wether the value Run = 1. If it doesn't, it hides that form and shows the wizard. If it does, it just continues
I'll try out the above code and see what happens
Logic is a systematic way of coming to the wrong conclusion with confidence.
-
Mar 23rd, 2004, 01:33 AM
#6
Thread Starter
Junior Member
OK, That code for Sub Main worked. Thanks a heap.
Logic is a systematic way of coming to the wrong conclusion with confidence.
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
|