Beginner Beginner - 1 year ago 90 Question

How to check if a string contains only numbers?

Dim number As String = "07747(a)"

If number.... Then


I want to be able to check inside the string to see if it only has number, if it does only contain numbers then run whatever is inside the if statment? What check do i use to check if the string only contains numeric and no alpha ot () etc ..?

What i am trying to check for is mobile numbers, so 077 234 211 should be accepted, but other alphas should not be

Answer Source

You could use a regular expression like this

If Regex.IsMatch(number, "^[0-9 ]+$") Then


End If
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download