View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Rick Rothstein \(MVP - VB\)[_1814_] Rick Rothstein \(MVP - VB\)[_1814_] is offline
external usenet poster
 
Posts: 1
Default IsNumber (in Rick Rothstein's example)

Rightfully, the function you posted should have been called IsDigits, not
IsNumber.

Give this function a try...

Function IsNumber(ByVal Value As String) As Boolean
' Uncomment the next statement out if you
' 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

Rick


"Sam Kuo" wrote in message
...
I'm trying to write a function that checks whether an input is a positive
number.

Below is one of Rick Rothstein's examples that he recommands for use in
replacement of IsNumeric. But I need to expand it further so only
"positive
whole number or integer" (i.e with or without decimal point) returns true.
While anything else with text, sign or symbol need to return false.

Any help is appreciated.

Function IsNumber(ByVal Value As String) As Boolean
IsNumber = Len(Value) 0 And Not Value Like "*[!0-9.]*"
End Function