Check string for non-numeric characters in VBScript

I am working on a Windows application written in VBScript, and I need to check the string for any non-numeric characters, in particular anything az. I understand that I could do this using the InStr () function in combination with a loop that checks az, but that just seems ridiculous. I have very little experience with VBScript, so I really don't know where to do this.

What is a good method to solve this situation?

+3
source share
3 answers

Use regex:

Set re = New RegExp
re.Pattern = "[a-z]"
re.IgnoreCase = True
re.Global = True
hasMatches = re.Test("12345abc")

If hasMatches = True Then
    ' it has letters
End If
+8
source

IsNumeric function ?

If IsNumeric(x) Then y = CDbl(x)
+2
source

, .

isnumeric, "", , . ! "§ $% & ..

+1

Source: https://habr.com/ru/post/1773993/


All Articles