Gruppe
Dialog
Problem
Es werden 5 verschiedene Varianten gezeigt, eine Zahleneingabe in eine InputBox zu erzwingen.
StandardModule: Modul1
Sub InputBoxA()
Dim lValue As Long
On Error GoTo ERRORHANDLER
lValue = InputBox("Bitte eine Ganzzahl eingeben:")
MsgBox lValue
Exit Sub
ERRORHANDLER:
MsgBox "Nur Zahlen erlaubt!"
Resume
End Sub
Sub InputBoxB()
Dim lValue As Long
lValue = Application.InputBox( _
prompt:="Bitte eine Ganzzahl eingeben:", _
Type:=1)
MsgBox lValue
End Sub
Sub InputBoxC()
Dim vValue As Variant
vValue = "Start"
Do While Not IsNumeric(vValue)
vValue = InputBox("Bitte eine Ganzzahl eingeben:")
Loop
MsgBox vValue
End Sub
Sub InputBoxD()
Dim vValue As Variant
Do
vValue = InputBox("Bitte eine Ganzzahl eingeben:")
If IsNumeric(vValue) Then Exit Do
Loop
MsgBox vValue
End Sub
Sub InputBoxE()
Dim lValue As Long
On Error Resume Next
Err.Raise 6
Do While Err
Err.Clear
lValue = InputBox("Bitte eine Ganzzahl eingeben:")
Loop
MsgBox lValue
End Sub