Results 1 to 3 of 3

Thread: Countdown timer

  1. #1

    Thread Starter
    New Member
    Join Date
    Feb 2000
    Location
    Cambs
    Posts
    2

    Post

    To VBWorld,
    Please could you tell me what is wrong with this code as when I run it, it just shows the label caption as -1. Please help and email me at [email protected]

    Private Sub Command1_Click()
    Timer1.Enabled = True
    End Sub

    Private Sub Form_Load()
    Dim snds
    snds = 60
    Label1.Caption = snds
    End Sub

    Private Sub Timer1_Timer()
    snds = snds - 1
    Label1.Caption = snds
    End Sub

    THANKS FOR ANY HELP YOU CAN GIVE ME
    jmcg
    [email protected]


    ------------------
    J.McGlory

  2. #2
    Addicted Member Razzle's Avatar
    Join Date
    Jan 2000
    Location
    Berlin, Germany
    Posts
    161

    Post

    That's problem which could be easier prevented when using Option Explicit...
    You didn't declare the snds variable global. Just write Dim snds at the top of the Form source (maybe use Public instead of Dim).
    Your variable was only declared for Form_Load but got the value 0 again when used in the timer.
    0 - 1 is -1

    ------------------
    Razzle
    ICQ#: 31429438

  3. #3

    Thread Starter
    New Member
    Join Date
    Feb 2000
    Location
    Cambs
    Posts
    2

    Post

    Thanx I'll try it out now

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