• home
  • forum
  • my
  • kt
  • download
  • A Simple Stropwatch!

    Author: 2008-09-13 17:51:47 From:

    Here is my GUI:

    This image has been resized. Click this bar to view the full image. The original image is sized 797x600 and weights 168KB.


    ------------------------------------------------------------------

    WHAT YOU NEED:

    2 Labels with:

    #1 Label:
    Name: Label1
    Caption: SIMPLE STOPWATCH

    #2 Label:
    Name: Label2
    Caption: 0.00

    4 Command Buttons with:

    #1 Command Button:
    Name: Command1
    Caption: START

    #2 Command Button:
    Name: Command2
    Caption: STOP

    #3 Command Button:
    Name: Command3
    Caption: RESET

    #4 Command Button:
    Name: Command4
    Caption: QUIT

    1 Timer with:
    Name: Timer1
    Caption: (None)
    Interval: 1

    ----------------------------------------------------------------

    CODE:

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

    Private Sub Command2_Click()
    Timer1.Enabled = False
    End Sub

    Private Sub Command3_Click()
    Label2.Caption = "0.00"
    End Sub

    Private Sub Command4_Click()
    End
    End Sub

    Private Sub Timer1_Timer()
    Label2.Caption = Format(Val(Label2.Caption) + 0.01, _
    "fixed")
    End Sub
    The code explanation follows.

    ----------------------------------------------------------------

    CODE EXPLANATION:

    Quote:
    Private Sub Command1_Click()
    Timer1.Enabled = True
    End Sub
    Enables the timer (Makes it start).

    ----------------------------------------------------------------

    Quote:
    Private Sub Command2_Click()
    Timer1.Enabled = False
    End Sub
    Disables the timer (Stops it).

    ----------------------------------------------------------------

    Quote:
    Private Sub Command3_Click()
    Label2.Caption = "0.00"
    End Sub
    This code tells VB that when Command3 (RESET) is clicked, change the caption of Label2 to 0.00.

    ----------------------------------------------------------------

    Quote:
    Private Sub Command4_Click()
    End
    End Sub
    Ends (Closes) the program.

    ----------------------------------------------------------------

    Quote:
    Private Sub Timer1_Timer()
    Label2.Caption = Format(Val(Label2.Caption) + 0.01, _
    "fixed")
    End Sub
    This means make Label2's caption change by adding +0.01 to it every millisecond.

    ----------------------------------------------------------------

    Thank you for reading this tutorial.

    Thanks to Tcm9669/TheComputerMaster for the Screenshot program.

    Made by me, Travy92.

    SAMPLES:
    Attached Files<>To view attachments your post count must be 1 or greater. Your post count is 0 momentarily.
    __________________
    Quote:
    The pacifist's task today is to find a method of helping and healing which provides a revolutionary constructive substitute for war.

    discuss this topic to forum

    relation tutorial

    No relevant information

    Category

      .NET (8)
      Buttons (3)
      Database Related (7)
      Date and Time (3)
      Development (4)
      Error Handling (3)
      File Manipulation (6)
      Introduction to Visual Basic (24)
      Miscellaneous (3)
      Multimedia (10)
      Networking (10)
      Security (1)
      VB Script (6)

    New

    Hot