PDA

View Full Version : Solved: userform to only accept mobile number



gringo287
03-14-2013, 03:39 PM
How do,

How would i set criteria to a userform textbox to only allow a valid 11 digit mobile number ?

SamT
03-14-2013, 05:28 PM
Restricting it to 11 numerical digits is common. So is formatting it with Spaces, parentheses and dashes, but...

How is it supposed to know a mobile number from a land line number?

You will have to provide a list of acceptable area codes, and maybe prefixes. Or list of unacceptable ones.

The list can be in the structure of a collection, a dictionary, a select case, Module Properties, or a simple list stored on a worksheet.

gringo287
03-14-2013, 05:35 PM
How is it supposed to know a mobile number from a land line number?

derrr:whistle:. Completely over looked that one.

what about keeping it simple and just stipulating that it has to start with 07?.

I'm happy to leave it to the possiblilty of the user sussing out that they could just type "07000000000", as 1/ this is unlikley.. and 2/ they will be pasting the number in most of the time, so its more, just a case of nudging the user to point out a typo more than anything.

SamT
03-14-2013, 06:23 PM
Reeeaaal Simple
If Left(TextBox1, 2)<> "07" Then TextBox1 = ""

gringo287
03-15-2013, 02:08 AM
Thanks for your help samT.... just to push my luck, how could that be adjusted to require 11 digits

SamT
03-15-2013, 06:46 PM
If Len(TextBox1) <> 11 then TextBox1 = ""

gringo287
03-17-2013, 11:42 AM
Thank you SamT, sorry for the late response