Dim number As String = "07747(a)" If number.... Then endif
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
Use the test() method on the following regular expression to check if a string contains only letters and numbers - /^[A-Za-z0-9]*$/ . The test method will return true if the regular expression is matched in the string and false otherwise.
On false , string has only numbers.
Python String isnumeric() Method The isnumeric() method returns True if all the characters are numeric (0-9), otherwise False. Exponents, like ² and ¾ are also considered to be numeric values. "-1" and "1.5" are NOT considered numeric values, because all the characters in the string must be numeric, and the - and the .
Using Character.isDigit(char ch). If the character is a digit then return true, else return false.
You could use a regular expression like this
If Regex.IsMatch(number, "^[0-9 ]+$") Then ... End If
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With