• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 75
  • Last Modified:

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.
0
SteveL13
Asked:
SteveL13
1 Solution
 
Rey Obrero (Capricorn1)Commented:
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
0
 
COACHMAN99Commented:
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
0
 
Gustav BrockCIOCommented:
As the Inputbox always returns a string, so should Nz, thus it should rather be:

Sub test1()
    If Val(Nz(InputBox("Enter Value"))) > 0 Then
        MsgBox "Good value"
    Else
        MsgBox "Please enter a value greater than 0"
    End If
End Sub 

Open in new window

/gustav
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now