Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Stopwatch by Fellippe Heitor
#1
   

Start, stop & determine lap times - it's a stopwatch. 

The program uses the following InForm objects:
Form
Button
ListBox


Unzip the file and extract the folder into your PEQB64 directory.  In the IDE make sure that you have the Run Option “Save EXE in source folder” checked.

.zip   Stopwatch.zip (Size: 114.03 KB / Downloads: 4)

Code: (Select All)
': Program by Fellippe Heitor
': This program uses
': InForm-PE for QB64-PE - v1.5.8 based upon InForm by Fellippe Heitor
': Copyright (c) 2025 QB64 Phoenix Edition Team
': https://github.com/QB64-Phoenix-Edition/InForm-PE
'-----------------------------------------------------------

OPTION _EXPLICIT

': Controls' IDs: ------------------------------------------------------------------
DIM SHARED Stopwatch AS LONG
DIM SHARED TimeLB AS LONG
DIM SHARED StartBT AS LONG
DIM SHARED LapBT AS LONG
DIM SHARED StopBT AS LONG
DIM SHARED ListBox1 AS LONG

DIM SHARED start AS SINGLE, Running AS _BYTE
DIM SHARED second AS INTEGER, minute AS INTEGER, hour AS INTEGER
DIM SHARED elapsed AS SINGLE

': External modules: ---------------------------------------------------------------
'$INCLUDE:'InForm\InForm.bi'
'$INCLUDE:'InForm\xp.uitheme'
'$INCLUDE:'Stopwatch.frm'


': Event procedures: ---------------------------------------------------------------
SUB __UI_BeforeInit
END SUB

SUB __UI_OnLoad
    __UI_DefaultButtonID = StartBT
END SUB

SUB __UI_BeforeUpdateDisplay
    IF Running THEN
        DIM theTime$

        elapsed = TIMER - start
        IF elapsed >= 1 THEN
            second = second + 1
            elapsed = elapsed - 1
            start = start + 1
            IF second >= 60 THEN
                second = second - 60
                minute = minute + 1
                IF minute >= 60 THEN
                    minute = minute - 60
                    hour = hour + 1
                END IF
            END IF
        END IF

        DIM hour$: hour$ = RIGHT$("00" + LTRIM$(STR$(hour)), 2)
        DIM min$: min$ = RIGHT$("00" + LTRIM$(STR$(minute)), 2)
        DIM sec$: sec$ = RIGHT$("00" + LTRIM$(STR$(second)), 2)
        DIM elapsed$: elapsed$ = MID$(STR$(elapsed), INSTR(STR$(elapsed), ".") + 1) + "000"

        theTime$ = hour$ + ":" + min$ + ":" + sec$ + "," + LEFT$(elapsed$, 3)

        Caption(TimeLB) = theTime$
    END IF
END SUB

SUB __UI_BeforeUnload
END SUB

SUB __UI_Click (id AS LONG)
    SELECT CASE id
        CASE Stopwatch

        CASE TimeLB

        CASE StartBT
            IF Running THEN
                Caption(id) = "Start"
                Running = False
                Control(StopBT).Disabled = False
                Control(LapBT).Disabled = True
            ELSE
                Caption(id) = "Pause"
                start = TIMER - elapsed
                Running = True
                Control(StopBT).Disabled = True
                Control(LapBT).Disabled = False
            END IF
        CASE LapBT
            AddItem ListBox1, Caption(TimeLB)
        CASE StopBT
            second = 0
            minute = 0
            hour = 0
            elapsed = 0
            Caption(TimeLB) = "00:00:00,000"
            ResetList ListBox1
        CASE ListBox1

    END SELECT
END SUB

SUB __UI_MouseEnter (id AS LONG)
    SELECT CASE id
        CASE Stopwatch

        CASE TimeLB

        CASE StartBT

        CASE LapBT

        CASE StopBT

        CASE ListBox1

    END SELECT
END SUB

SUB __UI_MouseLeave (id AS LONG)
    SELECT CASE id
        CASE Stopwatch

        CASE TimeLB

        CASE StartBT

        CASE LapBT

        CASE StopBT

        CASE ListBox1

    END SELECT
END SUB

SUB __UI_FocusIn (id AS LONG)
    SELECT CASE id
        CASE StartBT

        CASE LapBT

        CASE StopBT

        CASE ListBox1

    END SELECT
END SUB

SUB __UI_FocusOut (id AS LONG)
    SELECT CASE id
        CASE StartBT

        CASE LapBT

        CASE StopBT

        CASE ListBox1

    END SELECT
END SUB

SUB __UI_MouseDown (id AS LONG)
    SELECT CASE id
        CASE Stopwatch

        CASE TimeLB

        CASE StartBT

        CASE LapBT

        CASE StopBT

        CASE ListBox1

    END SELECT
END SUB

SUB __UI_MouseUp (id AS LONG)
    SELECT CASE id
        CASE Stopwatch

        CASE TimeLB

        CASE StartBT

        CASE LapBT

        CASE StopBT

        CASE ListBox1

    END SELECT
END SUB

SUB __UI_KeyPress (id AS LONG)
    SELECT CASE id
        CASE StartBT

        CASE LapBT

        CASE StopBT

        CASE ListBox1

    END SELECT
END SUB

SUB __UI_TextChanged (id AS LONG)
    SELECT CASE id
        CASE ELSE
    END SELECT
END SUB

SUB __UI_ValueChanged (id AS LONG)
    SELECT CASE id
        CASE ListBox1

    END SELECT
END SUB

SUB __UI_FormResized
END SUB

'$INCLUDE:'InForm\InForm.ui'
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Word Clock by Fellippe Heitor Magdha 0 86 02-09-2026, 11:38 AM
Last Post: Magdha
  InForm Paint by Fellippe Heitor Magdha 0 96 01-31-2026, 10:08 AM
Last Post: Magdha
  Fireworks by Fellippe Heitor Magdha 0 95 01-30-2026, 10:03 AM
Last Post: Magdha

Forum Jump:


Users browsing this thread: 1 Guest(s)