I understand the input box but can’t prompt user if it’s empty. I’m getting confused on this. Can someone explain?
’ Ask the user for an integer. Convert user input
’ from a string to an integer.
Dim num As Integer
num% = CInt(InputBox$(“How many do you want?”))
’ this is wrong…If Isempty(num) = “” Then
Msgbox "Canceled Program."
Exit Sub
End If
Subject: confused in inputbox conversion
You should also do some check to make sure the value the user entered is a number.
Sub Click(Source As Button)
Dim ask As String
Dim num As Variant
askagain:
ask = Inputbox$("How many do you want?")
If ask = "" Then
Msgbox "Canceled Program."
Goto askagain
End If
If Isnumeric(ask) Then
num = Cint(ask)
Else
Msgbox "You must enter a number"
Goto askagain
End If
End Sub
Subject: RE: confused in inputbox conversion
Ok, got it. I put the If Not Isnumeric(field) in there and it’s working fine. Thanks.