|
-
Apr 27th, 2006, 07:28 AM
#1
Thread Starter
Addicted Member
[RESOLVED] Problem with visibility
VB Code:
Public Sub Form_Load()
If Label1.Visible = True Then
lvl = 1
stre = 10
dex = 2
hp = 10
End If
level.Caption = lvl
strength.Caption = stre
dexterity.Caption = dex
health.Caption = hp
End Sub
Why aren't the labels getting the variables lvl, stre, dex and hp assigned to them? If anyone has a solution, please tell me.
-
Apr 27th, 2006, 07:30 AM
#2
Re: Problem with visibility
my guess would be that label1 is not visible...
if u do this does it work?
VB Code:
Public Sub Form_Load()
'If Label1.Visible = True Then
lvl = 1
stre = 10
dex = 2
hp = 10
'End If
level.Caption = lvl
strength.Caption = stre
dexterity.Caption = dex
health.Caption = hp
End Sub
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
-
Apr 27th, 2006, 07:32 AM
#3
Re: Problem with visibility
nothing is visible at Form_Load because the form isn't visible
-
Apr 27th, 2006, 07:32 AM
#4
Thread Starter
Addicted Member
Re: Problem with visibility
Yes, but the label in question is visible, so shouldn't it work?
-
Apr 27th, 2006, 07:38 AM
#5
Re: Problem with visibility
 Originally Posted by bushmobile
nothing is visible at Form_Load because the form isn't visible
Thats right to some extent. Theoritically they are visible unless their Visible property is not set to false.
 Originally Posted by ajames
Yes, but the label in question is visible, so shouldn't it work?
The only thing that comes to my mind is that the Label1's visible property is either set to false or the visible property of other labels is set false.
Use [code] source code here[/code] tags when you post source code.
My Articles
-
Apr 27th, 2006, 07:39 AM
#6
Re: Problem with visibility
Private Sub Command1_Click()
If Label1.Visible = True Then
A = "SHAKTI"
Label1.Caption = A
End If
End Sub
-
Apr 27th, 2006, 07:40 AM
#7
Re: Problem with visibility
 Originally Posted by Shuja Ali
Thats right to some extent. Theoritically they are visible unless their Visible property is not set to false.
If Form.Visible = False then all controls .Visible = False
there's nothing theoretical about it.
-
Apr 27th, 2006, 07:43 AM
#8
Re: Problem with visibility
 Originally Posted by bushmobile
If Form.Visible = False then all controls .Visible = False
there's nothing theoretical about it.
That is completely, 100%, totally correct and the Form will not be visible until ALL code in the Form_Load has executed.
This is why errors are generated when you try to SetFocus to a control in the Form_Load.
Move your code to the Form_Activate event instead of Form_Load and you should be fine.
-
Apr 27th, 2006, 07:52 AM
#9
Thread Starter
Addicted Member
Re: Problem with visibility
Thanks for all of your help
[RESOLVED]
-
Apr 27th, 2006, 08:08 AM
#10
Re: Problem with visibility
 Originally Posted by bushmobile
If Form.Visible = False then all controls .Visible = False
there's nothing theoretical about it.
Lets do a small test then. Open a new project in VB, put a label (Label1) on the Form and write this code in Form Load Event
VB Code:
Private Sub Form_Load()
If Label1.Visible Then
MsgBox "Lable is visible"
Else
MsgBox "Label is not visible"
End If
End Sub
Now run the code and see yourself what is happening.
Use [code] source code here[/code] tags when you post source code.
My Articles
-
Apr 27th, 2006, 08:14 AM
#11
Re: [RESOLVED] Problem with visibility
Well it appears that we're all wrong.
Controls with hWnd are Visible = False at form load
Controls without hWnd are Visible = True at form load
Probably best just err on the side of everything isn't visible.
-
Apr 27th, 2006, 08:19 AM
#12
Re: [RESOLVED] Problem with visibility
Thats right. Probably because the controls with the HWND have the Form as their owner so when owner is not visible the controls will also not be visible.
This is just a wild guess.
Use [code] source code here[/code] tags when you post source code.
My Articles
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
|