Using InputBox- Numbers only- Help?

Need a little help here. I'm using an input box. I only want a numerical input. No letters. How do I make sure it only accepts numbers? Is this possible?

Here's the script:

Sub object_onscriptenter
object.Text= object.PersistStorage("newtext")
End Sub

Sub Object_OnLbuttonup(x,y,dragged)
Dim Input
If Not dragged Then
Input = InputBox("Enter seconds 1-5")
If Input < 6 Then
If Input > 0 Then
object.PersistStorage("newtext")= Input
Object.Text= object.PersistStorage("newtext")
End If
End If
End If

End Sub


Thanks.
3,513 views 5 replies
Reply #1 Top
Use IsNumeric(expression) to return True or False whether the Input box holds a number. Then
CInt the InputBox and use the number.
Reply #2 Top
Thanks Skarnivorous, it worked.
Reply #3 Top
or use a drop down box control with only those numbers in it

Reply #4 Top
Mind you, you can use less if statements in that code:


Sub object_onscriptenter
object.Text= object.PersistStorage("newtext")
End Sub

Sub Object_OnLbuttonup(x,y,dragged)
Dim Input
If Not dragged Then
Input = InputBox("Enter seconds 1-5")
If IsNumberic(Input) And Input < 6 And Input > 0 Then
object.PersistStorage("newtext")= Input
Object.Text= object.PersistStorage("newtext")
End If
End If

End Sub
Reply #5 Top
Thanks for the tips you guys.