Option
Explicit
Private
Sub
CommandButton1_Click()
Dim
datWaitTime
As
Date
Dim
datTimeToWait
As
Date
, datEnde
As
Date
Dim
intValue
As
Integer
datWaitTime = TimeValue(
"00:00:05"
)
datTimeToWait = datWaitTime
datEnde = Now + datTimeToWait
Call
warten(datEnde)
intValue = get_Input()
Do
While
intValue > 8
datTimeToWait = datTimeToWait + datWaitTime
datEnde = Now + datTimeToWait
Call
warten(datEnde)
intValue = get_Input()
Loop
MsgBox
"Eingegebene Wert war kleiner als 8!"
, vbInformation
End
Sub
Private
Sub
warten(
ByVal
TimerEnde
As
Date
)
If
TimerEnde < Now
Then
MsgBox
"Ende TimerEnde ist bereits erreicht.."
Exit
Sub
End
If
Do
While
Now < TimerEnde
Call
Sleep(1000)
With
Me
.TextBox1.Value = Format(TimerEnde - Now,
"Hh:Nn:Ss"
)
.Repaint
End
With
DoEvents
Loop
End
Sub
Private
Function
get_Input()
As
Integer
Dim
strInput
As
String
strInput = InputBox(
"Bitte geben Sie einen numerischen Wert ein:"
)
If
Not
IsNumeric(strInput)
Then
MsgBox
"Der eingegebene Wert ist nicht nummerisch, beende Programm."
get_Input = 0
Exit
Function
Else
get_Input =
CInt
(strInput)
End
If
End
Function