Consulting

Results 1 to 7 of 7

Thread: Solved: userform to only accept mobile number

  1. #1

    Solved: userform to only accept mobile number

    How do,

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

  2. #2
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    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.

  3. #3
    Quote Originally Posted by SamT
    How is it supposed to know a mobile number from a land line number?
    derrr. 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.

  4. #4
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    Reeeaaal Simple
    [VBA]If Left(TextBox1, 2)<> "07" Then TextBox1 = ""[/VBA]

  5. #5
    Thanks for your help samT.... just to push my luck, how could that be adjusted to require 11 digits

  6. #6
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    [VBA]If Len(TextBox1) <> 11 then TextBox1 = ""[/VBA]

  7. #7
    Thank you SamT, sorry for the late response

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •