Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
IsAlpha etc
#9
(01-21-2026, 10:45 PM)ahenry3068 Wrote: Here's IsNum

Code: (Select All)

Function IsNum% (PassedText As String)
dim text$, temp$
dim special$
dim r$
dim r2$
dim r3$
dim check$
dim I as integer

    text$ = PassedText
    special$ = UCase$(Left$(text$, 2))
    Select Case special$
        Case "&H", "&B", "&O"
            'check for symbols on right side of value
            r3$ = Right$(text$, 3)
            Select Case r3$
                Case "~&&", "~%%", "~%&" 'unsigned int64, unsigned byte, unsigned offset
                    text$ = Left$(text$, Len(text$) - 3)
                Case Else
                    r2$ = Right$(text$, 2)
                    Select Case r2$
                        Case "~&", "##", "%&", "%%", "~%", "&&" 'unsigned long, float, offset, byte, unsigned integer, int64
                            text$ = Left$(text$, Len(text$) - 2)
                        Case Else
                            r$ = Right$(text$, 1)
                            Select Case r$
                                Case "&", "#", "%", "!" 'long, double, integer, single
                                    text$ = Left$(text$, Len(text$) - 1)
                            End Select
                    End Select
            End Select
            check$ = "0123456789ABCDEF"
            If special$ = "&O" Then check$ = "01234567"
            If special$ = "&B" Then check$ = "01"
            temp$ = Mid$(UCase$(text$), 2)
            For I = 1 To Len(temp$)
                If InStr(check$, Mid$(temp$, I, 1)) = 0 Then Exit For
            Next
            If I <= Len(temp$) Then IsNum = -1
        Case Else
            If _Trim$(Str$(Val(text$))) = text$ Then IsNum = -1
    End Select
End Function

Note that this can fail with scientific notation values.
Reply


Messages In This Thread
IsAlpha etc - by PhilOfPerth - 01-21-2026, 10:36 PM
RE: IsAlpha etc - by ahenry3068 - 01-21-2026, 10:45 PM
RE: IsAlpha etc - by SMcNeill - 01-22-2026, 05:44 PM
RE: IsAlpha etc - by ahenry3068 - 01-21-2026, 10:56 PM
RE: IsAlpha etc - by ahenry3068 - 01-21-2026, 11:07 PM
RE: IsAlpha etc - by Pete - 01-22-2026, 12:09 AM
RE: IsAlpha etc - by ahenry3068 - 01-22-2026, 12:23 AM
RE: IsAlpha etc - by PhilOfPerth - 01-22-2026, 12:41 AM
RE: IsAlpha etc - by SMcNeill - 01-22-2026, 04:14 PM
RE: IsAlpha etc - by a740g - 01-22-2026, 06:03 PM
RE: IsAlpha etc - by PhilOfPerth - 01-22-2026, 10:32 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)