Visual basic 2005, only allow number in textbox

August 1st, 2016

hello, i am trying to validate a text box to make sure users dont type text or leave the text box empty( i only want numbers). I dont know most of the commands for VB as i am a php programmer any help would be much appreciated
Answer #1
These are two functions i found on the Web:
Function IsDigitsOnly(Value As String) As Boolean
IsDigitsOnly = Len(Value) > 0 And _
Not Value Like “*[!0-9]*”
End Function
Function IsNumber(ByVal Value As String) As Boolean
‘ Leave the next statement out if you don’t
‘ want to provide for plus/minus signs
If Value Like “[+-]*” Then Value = Mid$(Value, 2)
IsNumber = Not Value Like “*[!0-9.]*” And _
Not Value Like “*.*.*” And _
Len(Value) > 0 And Value <> “.” And _
Value <> vbNullString
End Function
http://www.thescripts.com/forum/thread14378.html
Thats the link, in the 2nd reply the guy says why he doesnt use IsNumeric()
Hope this was helpful
PM if you have problems

 

| Sitemap |