3

I'm working on a Windows application that's written in VBScript and I need to check a string for any non-numeric characters, specifically anything a-z. I realize I could probably do this using the InStr() function in conjunction with a loop that checks for a-z but that just seems ridiculous. I have very little experience in VBScript so I really don't know where to go on this.

What's a good method for handling this kind of situation?

3 Answers 3

8

Use a regular expression:

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
Sign up to request clarification or add additional context in comments.

1 Comment

Worked great, btw. Thank you!
2

The IsNumeric function?

If IsNumeric(x) Then y = CDbl(x)

Comments

1

a little late but an answer.

if you work with isnumeric and you set a Not in front to check if there is NO NUMBER. But every sign like !"§$%& and so on will be ignored and will be put into the check

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.