AccessBlog.net

News, links, downloads, tips and tricks on Microsoft Access and related

About Me Search
Alex
Name:Alex Dybenko

Location:Moscow, Russia

Friday, September 21, 2012

How to check that user enters only digits

IsNumeric() function returns true for a string, which can me converted to number, like "1 2", "1e2". But if you need to check that string contains only digits? The simplest way I think is:

If strVar Like String(Len(strVar),"#") then
       'Only numbers!
End If

Labels:

2 Comments:

Anonymous JP said...

What about

Function IsDigitsOnly(strVar As String) As Boolean
IsDigitsOnly = (strVar Like "[0-9]")
End Function

6:39 PM  
Anonymous JP said...

Sorry, that's not correct.

6:41 PM  

Post a Comment

<< Home