Results 1 to 14 of 14

Thread: Blinking Label

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Oct 2000
    Posts
    98

    Exclamation

    I have looked and tried some of the examples from VB World.

    I have a label with the caption "Please wait..."

    This label is only to appear when i click on the command button...
    Many exmaples VB WORLD have the label appearing when the form loads eventhough the label at design time is set to false and the property on the control is false and the form load there is nothing about the label...


    I want the label to blink when the user clicks on the command button or any other ideas but i want to keep it simple


    Can anyone paste some code to show me


    Thank you
    Steve

  2. #2
    Lively Member
    Join Date
    Aug 2000
    Posts
    125
    put a label, a timer and a commandbutton on a form

    Code:
    Private Sub Command1_Click()
        Timer1.Enabled = Not Timer1.Enabled
        Label1.Visible = Timer1.Enabled
    End Sub
    
    Private Sub Form_Load()
        Timer1.Enabled = False
        Timer1.Interval = 500
        Label1.Caption = ""
        Label1.Visible = False
    End Sub
    
    Private Sub Timer1_Timer()
        If Label1.Caption = "" Then
            Label1.Caption = "Please Wait..."
        Else
            Label1.Caption = ""
        End If
    End Sub

  3. #3
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Code:
    Private Declare Function GetTickCount Lib "kernel32" () As Long
    
    Private Sub Command1_Click()
        Dim temp As String
        Do
            temp = Label1.Tag
            Label1.Tag = Label1
            Label1 = temp
            X = GetTickCount + 500
            Do Until X < GetTickCount Or Forms.Count = 0
                DoEvents
            Loop
        Loop Until stopdoingthis Or Forms.Count = 0
    End Sub
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Oct 2000
    Posts
    98

    Talking Reply - Kedaman

    Works great!
    Label blinks and there is no opening pause

    The only question is how to I get out of this loop?
    I can not get out of the loop and my system does not execute!

    Steve


  5. #5
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    the stopdoingthis i wrote there in my code was meant to show you, you put the boolean variable or expression to determine when to exit the loop
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  6. #6

    Thread Starter
    Lively Member
    Join Date
    Oct 2000
    Posts
    98

    Reply - Kedaman

    Kedaman..

    Can you help me get out of the loop?

    I want it to stop when the frmoption displays...

    Thank you,
    Steve

  7. #7
    Frenzied Member Jop's Avatar
    Join Date
    Mar 2000
    Location
    Amsterdam, the Netherlands
    Posts
    1,986
    I can help you...
    change this line

    Code:
    Loop Until stopdoingthis Or Forms.Count = 0
    to
    Code:
    Loop Until stopdoingthis Or Forms.Count = 0 Or frmOption.Visible
    Jop - validweb.nl

    Alcohol doesn't solve any problems, but then again, neither does milk.

  8. #8

    Thread Starter
    Lively Member
    Join Date
    Oct 2000
    Posts
    98

    relpy

    Do I have to use a loop
    Is there any other way of disabling the blinking?

    I put the Loop Until stopdoingthis Or Forms.Count = 0 Or frmOption.Visible
    at the end of my code and the pause is still there

  9. #9
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    Code:
    Private Declare Function GetTickCount Lib "kernel32" () As Long
    Public stopdoingthis As Boolean
    
    
    Private Sub Command1_Click()
    stopdoingthis = False
        Dim temp As String
        Do
            temp = Label1.Tag
            Label1.Tag = Label1
            Label1 = temp
            X = GetTickCount + 500
            Do Until X < GetTickCount Or Forms.Count = 0
                DoEvents
            Loop
        Loop Until stopdoingthis = True
        
    End Sub
    
    
      
    Private Sub Label1_Click()
    'wherever you make frmOption visible or whatever
      stopdoingthis = True
      
    End Sub
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  10. #10

    Thread Starter
    Lively Member
    Join Date
    Oct 2000
    Posts
    98

    Angry Reply

    Here is my code:

    How do i get out of the loop ?
    If I put my code between the Do Until and the loop, the label never actually blinks...

    Dim Msg, Style, Title, Response

    lblTimer.Visible = True
    tmr1.Enabled = True
    stopdoingthis = False
    Dim temp As String
    Do
    temp = lblTimer.Tag
    lblTimer.Tag = lblTimer
    lblTimer = temp
    X = GetTickCount + 500
    Do Until X < GetTickCount Or Forms.Count = 0
    DoEvents
    Loop
    Loop Until stopdoingthis Or Forms.Count = 0 Or frmOption.Visible

    Set myWorkBook = myExeclApp.Workbooks.Open("d:\temp\temp.xls")
    Set myWorksheet = myWorkBook.Worksheets(2)

  11. #11
    Frenzied Member Jop's Avatar
    Join Date
    Mar 2000
    Location
    Amsterdam, the Netherlands
    Posts
    1,986
    HeSaidJoe's code works perfectly for me, don't see the point

    where do you put your code?
    Jop - validweb.nl

    Alcohol doesn't solve any problems, but then again, neither does milk.

  12. #12

    Thread Starter
    Lively Member
    Join Date
    Oct 2000
    Posts
    98
    I am having problems here:

    The pause is when I open the excel spreadsheet
    Can someone please help me fix this problem
    After the excel opens I want to have the label stop blinking

    Dim Msg, Style, Title, Response

    lblTimer.Visible = True
    tmr1.Enabled = True
    stopdoingthis = False
    Dim temp As String
    Do
    temp = lblTimer.Tag
    lblTimer.Tag = lblTimer
    lblTimer = temp
    X = GetTickCount + 500
    Do Until X < GetTickCount Or Forms.Count = 0
    DoEvents
    Set myWorkBook =myExeclApp.Workbooks.Open
    ("d:\temp\temp.xls")
    Set myWorksheet = myWorkBook.Worksheets(2)

    Loop
    Loop Until stopdoingthis Or Forms.Count = 0 Or frmOption.Visible


  13. #13
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>


    Use the code from kedaman and the added piece by myself.
    Change your label caption to read. "Click here to open file" or whatver your instructions would be.

    Then put your code for open excel in the label click event with my code and away you go.

    As you have it you are firing off a blink and opening a file and telling it to stop blinking when you open. It's all happening at once. I can't see how it will blink when you open at the same time.




    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  14. #14
    Member
    Join Date
    Jul 2000
    Posts
    48

    Talking

    This do the same, but less code.
    for lasy programmers!!




    Option Explicit

    Private Sub cmdconnect_Click()
    Timer1.Interval = 400
    Label1.Caption = "Please wait..."
    End Sub


    Private Sub Timer1_Timer()
    Label1.Visible = Not Label1.Visible
    End Sub

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