Link to home
Start Free TrialLog in
Avatar of SteveL13
SteveL13Flag for United States of America

asked on

Input box criteria

Is there a way to make a user enter a value greater than 0 in an input box?  In other words, 1 or greater.
Avatar of Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1)
Flag of United States of America image

you can check/verify if the value entered is not equal to 0

If InputBox("Enter Value") >= 1 Then
    msgbox "Good value"
    else
    MsgBox "Please enter a value greater than 0"
 
End If
Avatar of COACHMAN99
COACHMAN99

if you extend Rey's code it will accommodate strings, nulls etc.
Sub test1()
If Val(Nz(InputBox("Enter Value"), 0)) > 0 Then
     MsgBox "Good value"
     Else
     MsgBox "Please enter a value greater than 0"
 End If
End Sub
ASKER CERTIFIED SOLUTION
Avatar of Gustav Brock
Gustav Brock
Flag of Denmark image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial