mike55 Posted August 7, 2007 Posted August 7, 2007 I need to validate the first two characters of a mobile phone number. I know that the length of the number is 10 characters, and that the first two will be 0 and 8. The third character can be either 5, 6, 7, or 8. I have been going through various tutorials, but I am hitting a brick wall. Mike55. Quote A Client refers to the person who incurs the development cost. A Customer refers to the person that pays to use the product. ------ My software never has bugs. It just develops random features. (Mosabama vbforums.com)
MrPaul Posted August 7, 2007 Posted August 7, 2007 Phone number regex A regular expression to validate the entire number might look like this: \b08[5-8][0-9]{7}\b If the first number is anything but 0, there will be no match. If the second number is anything but 8, there will be no match. If the third number is anything but 5, 6, 7 or 8 there will be no match. If the total length of the number is not exactly 10, there will be no match. You can test your regexes at somewhere like REGex TESTER. Good luck :cool: Quote Never trouble another for what you can do for yourself.
techmanbd Posted August 7, 2007 Posted August 7, 2007 can you use the substring to get the first 3 numbers and then seperate the 3 through a loop and compare? dim str as string = "0123456789" str = str.substring(0,3) ' str = "012" for intL as integer = 1 to 3 'break down and compare code here end for or if you know the first to always the same, and need to check the last number dim str as string = "0123456789" 'string of the number str = str.substring(0,3) ' str = "012" dim boolCompare as boolean boolCompare = str.EndsWith("5") 'If the 3 digits in with 5 then will return true Ho[pefully this will get you on yor way. Quote Live as if you were to die tomorrow. Learn as if you were to live forever. Gandhi
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.