Code:Option Explicit Dim StartTime As Long, Mincount As Integer Dim Minutes As String, Seconds As String Dim TimeA As Long, TimeB As Long Dim GameLength As Integer ' Playing Time in Seconds Private Sub timeClock_Timer() ' Dim lTemp As Long ' Dim lTemp2 As Long ' intCounter = intCounter - 1000 ' lTemp = intCounter ' lTemp = lTemp / 1000 'convert to seconds ' lTemp2 = lTemp ' lTemp = (lTemp / 60) Mod 60 'Minutes ' lTemp2 = (lTemp2 Mod 60) 'Seconds ' If lTemp2 < 10 Then ' lblTime.Caption = lTemp & ":0" & lTemp2 ' Else ' lblTime.Caption = lTemp & ":" & lTemp2 ' End If ' If intCounter = 0 Then ' timeClock.Enabled = False ' MsgBox "Times up" ' End If If (Timer - StartTime) / (Mincount + 1) > 60 Then Mincount = Mincount + 1 Seconds = Format$(60 * (Mincount + 1) - (Timer - StartTime), "00") If Seconds = "60" Then Seconds = "00" If GameLength - (Timer - StartTime) > 60 Then Minutes = Format$((GameLength - (Timer - StartTime)) \ 60, "00:") lblTime.Caption = Replace(Minutes & Seconds, "01:", "1:") ElseIf GameLength - (Timer - StartTime) > 0 Then lblTime.Caption = Replace(Format$(60 * (Mincount + 1) - (Timer - StartTime), "00:00.0"), "00:", "") Else: 'MsgBox "Game Over!" End If End Sub Private Sub cmdClock_Click() If lblTime.Caption = "0:00" Then 'intCounter = 150000 '20 minutes End If If cmdClock.Caption = "Start Clock" Then timeClock.Interval = 500 TimeA = Timer StartTime = StartTime - Timer StartTime = StartTime + (TimeA - TimeB) ' timeClock.Enabled = False ' cmdClock.Caption = "Start Clock" ' Else ' timeClock.Enabled = True cmdClock.Caption = "Stop Clock" TimeB = Timer Else timeClock.Enabled = False End If End Sub Private Sub Form_Load() cmdClock.Caption = "Start Clock" GameLength = 120 StartTime = Timer End Sub




Reply With Quote