Results 1 to 12 of 12

Thread: [RESOLVED] Problem with visibility

  1. #1

    Thread Starter
    Addicted Member ajames's Avatar
    Join Date
    Mar 2005
    Location
    Wales, UK
    Posts
    178

    Resolved [RESOLVED] Problem with visibility

    VB Code:
    1. Public Sub Form_Load()
    2. If Label1.Visible = True Then
    3.     lvl = 1
    4.     stre = 10
    5.     dex = 2
    6.     hp = 10
    7. End If
    8. level.Caption = lvl
    9. strength.Caption = stre
    10. dexterity.Caption = dex
    11. health.Caption = hp
    12. 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.

  2. #2
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: Problem with visibility

    my guess would be that label1 is not visible...
    if u do this does it work?
    VB Code:
    1. Public Sub Form_Load()
    2. 'If Label1.Visible = True Then
    3.     lvl = 1
    4.     stre = 10
    5.     dex = 2
    6.     hp = 10
    7. 'End If
    8. level.Caption = lvl
    9. strength.Caption = stre
    10. dexterity.Caption = dex
    11. health.Caption = hp
    12. End Sub
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  3. #3
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: Problem with visibility

    nothing is visible at Form_Load because the form isn't visible

  4. #4

    Thread Starter
    Addicted Member ajames's Avatar
    Join Date
    Mar 2005
    Location
    Wales, UK
    Posts
    178

    Re: Problem with visibility

    Yes, but the label in question is visible, so shouldn't it work?

  5. #5
    Shared Member
    Join Date
    May 2005
    Location
    Kashmir, India
    Posts
    2,277

    Re: Problem with visibility

    Quote 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.

    Quote 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

  6. #6
    Just Married shakti5385's Avatar
    Join Date
    Mar 2006
    Location
    Udaipur,Rajasthan(INDIA)
    Posts
    3,747

    Arrow Re: Problem with visibility

    Private Sub Command1_Click()
    If Label1.Visible = True Then
    A = "SHAKTI"
    Label1.Caption = A
    End If
    End Sub

  7. #7
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: Problem with visibility

    Quote 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.

  8. #8
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Problem with visibility

    Quote 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.

  9. #9

    Thread Starter
    Addicted Member ajames's Avatar
    Join Date
    Mar 2005
    Location
    Wales, UK
    Posts
    178

    Re: Problem with visibility

    Thanks for all of your help
    [RESOLVED]

  10. #10
    Shared Member
    Join Date
    May 2005
    Location
    Kashmir, India
    Posts
    2,277

    Re: Problem with visibility

    Quote 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:
    1. Private Sub Form_Load()
    2.     If Label1.Visible Then
    3.         MsgBox "Lable is visible"
    4.     Else
    5.         MsgBox "Label is not visible"
    6.     End If
    7. 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

  11. #11
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    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.

  12. #12
    Shared Member
    Join Date
    May 2005
    Location
    Kashmir, India
    Posts
    2,277

    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
  •  



Click Here to Expand Forum to Full Width