If you do this often, as I do, you may like this "AllNumeric" function.
(There is an "IsNumeric" function, but it returns true for any numeric string
including minus signs and decimal points, etc.)
(main code...)
Dim MyInput As String
'
Do While Len(MyInput) <> 10 Or Not AllNumeric(MyInput)
MyInput = InputBox("Enter a 10-digit number")
Loop
'
MsgBox """" & MyInput & """"
'
(end main code...)
Private Function AllNumeric(txt As String) As Boolean
'
Dim Digit As String
Dim i As Long
'
For i = 1 To Len(txt)
Digit = Mid(txt, i, 1)
AllNumeric = Digit >= "0" And Digit <= "9"
If Not AllNumeric Then Exit Function
Next i
'
AllNumeric = True
'
End Function
"Tempy" wrote:
> Good day,
> I am requesting the user to enter a ten digit number into the input box
> and would like to test this and if not ten digits, then they must
> re-enter.
> Could somebody please help me with this, im sure simple code.
>
> thanks in advance
>
> Tempy
>
> *** Sent via Developersdex http://www.developersdex.com ***
>
Bookmarks