Results 1 to 7 of 7

Thread: [RESOLVED] Making a labelbox visible

  1. #1

    Thread Starter
    Hyperactive Member AccessShell's Avatar
    Join Date
    Oct 2013
    Posts
    464

    Resolved [RESOLVED] Making a labelbox visible

    On Win 10.

    I have a label box set to visible = false.

    In code, I set the labelbox visible to true
    Code:
    Me.lblBP.Visible = True
    If I step thru the program, the label becomes visible. Later in the code, I make it not visible. It becomes not visible(= false)

    However, If i run the program (not stepping through it), the label box does NOT become visible.

    Can anyone explain why and what I might do to fix it?

    Thanks

  2. #2
    Frenzied Member
    Join Date
    Nov 2017
    Posts
    1,657

    Re: Making a labelbox visible

    Quote Originally Posted by AccessShell View Post
    On Win 10.

    I have a label box set to visible = false.

    In code, I set the labelbox visible to true
    Code:
    Me.lblBP.Visible = True
    If I step thru the program, the label becomes visible. Later in the code, I make it not visible. It becomes not visible(= false)

    However, If i run the program (not stepping through it), the label box does NOT become visible.

    Can anyone explain why and what I might do to fix it?

    Thanks
    How much later in the code and what is the code between making it visible and making it not visible again?

    Try adding Me.lblBP.Refresh immediately after making it visible. That should force it to be displayed in the case that the subsequent code is taking priority over the label actually getting displayed.

  3. #3
    Frenzied Member
    Join Date
    Nov 2017
    Posts
    1,657

    Re: Making a labelbox visible

    Here is an example:

    Create a new project, add a button and a label to the form. Set the label's Visible property to false.

    Paste this code in the Button_Click event:

    Code:
      Dim i As Long
      Dim j As Long
      Label1.Visible = True
      'Label1.Refresh
      For i = 1 To 100000000
        For j = 1 To 100000000
        Next j
      Next i
    Run it with the .Refresh statement commented out. The label likely won't be displayed.
    Now run it with the .Refresh statement enabled. The label will be displayed.

    Remember that to break out of a "busy-loop" program in the IDE, press CTRL+Pause.

  4. #4

    Thread Starter
    Hyperactive Member AccessShell's Avatar
    Join Date
    Oct 2013
    Posts
    464

    Re: Making a labelbox visible

    I solved the problem. Instead of the time loop as suggested by OptionBase1, I did what should not be done. I'm sure I will chastized for it.

    First I put the code to make visible or not visible into a function. The after the startement Me.lblBP.Visible = True, I put in 2 DoEvents.
    That's not good code, but it works and it's only for me.

  5. #5
    Frenzied Member
    Join Date
    Nov 2017
    Posts
    1,657

    Re: Making a labelbox visible

    Quote Originally Posted by AccessShell View Post
    Instead of the time loop as suggested by OptionBase1
    Umm...yeah. That wasn't a suggestion at all. That was code that demonstrates when the label remains not visible even when visible has been set to True.

    The suggestion was to call the Refresh method of the label immediately after it is made visible. DoEvents will also accomplish it. That is a bit of a nuke to destroy a hornet's nest, but hey - its your own universe, nuke away.

  6. #6
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    13,694

    Re: [RESOLVED] Making a labelbox visible

    Yes there no reason to use doevents, it should not even be considered as an option. Use the refresh method. It will do the job just fine.

  7. #7

    Thread Starter
    Hyperactive Member AccessShell's Avatar
    Join Date
    Oct 2013
    Posts
    464

    Re: [RESOLVED] Making a labelbox visible

    Yes. I used the Refresh Method. The label was displayed properly.

    Thanks to all

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