Results 1 to 5 of 5

Thread: Basic Time Question NEED HELP

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2002
    Location
    Canada
    Posts
    7

    Question Basic Time Question NEED HELP

    This is probably a very simple question but I'm just starting to get the hang of this VB thing. It's very simple, I want to be able to click a buton and the program starts counting minutes.

    Click once, timer starts

    click another button and timer stops

    displays minutes in a textbox.

    any help would be great. Thanks

  2. #2
    Member bizzyVB's Avatar
    Join Date
    Jun 2001
    Location
    Florida
    Posts
    38
    make 2 command buttons
    name them cmdStartTimer and cmdStopTimer..

    VB Code:
    1. Private Sub cmdStartTimer_Click()
    2. Timer1.Enabled = True
    3. End Sub
    4.  
    5. Private Sub cmdStopTimer_Click()
    6. Timer1.Enabled = False
    7. End Sub
    8.  
    9. Private Sub Form_Load()
    10. Text1.Text = "0"
    11. Timer1.Interval = 1000
    12. Timer1.Enabled = False
    13. End Sub
    14.  
    15. Private Sub Timer1_Timer()
    16. Text1.Text = Val(Text1.Text) + 1
    17. End Sub

    basically this is the code with no formatting to the text..

  3. #3
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170
    VB Code:
    1. Public a As Integer
    2.  
    3.  
    4. Private Sub Command1_Click()
    5. If Timer1.Enabled = True Then
    6. Timer1.Enabled = False
    7. Else
    8. Timer1.Enabled = True
    9. End If
    10.  
    11.  
    12.  
    13. End Sub
    14.  
    15. Private Sub Form_Load()
    16. Timer1.Enabled = False
    17.  
    18. End Sub
    19.  
    20. Private Sub Timer1_Timer()
    21. a = a + 1
    22. Text1.Text = a
    23.  
    24.  
    25.  
    26. End Sub

    If u need any explanation, jes ask

  4. #4
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170
    *** happened to the spaces in [Highlight=VB]???

  5. #5
    Member bizzyVB's Avatar
    Join Date
    Jun 2001
    Location
    Florida
    Posts
    38
    btw my code counts seconds, so to count by minutes just set the interval of the timer to 60000.

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