+ Reply to Thread
Results 1 to 6 of 6

Check on the input in an inputbox

Hybrid View

  1. #1
    Neil
    Guest

    RE: Check on the input in an inputbox

    Put your number in to string variable eg A$

    Use the following code to test the length of the string

    If Len(A$) <>10 Then
    MsgBox ("Incorrect number")
    'Do something else to make your user re-enter the number
    End If

    Once added to your code the user will only be able to proceed when the
    variable is ten characters long. Note - this will only check for string
    length not validity, so letters and numbers can both be used, you will need
    to add seperate validation for those.

    HTH

    Neil
    www.nwarwick.co.uk

    "Tempy" wrote:

    > Good day,
    > I am requesting the user to enter a ten digit number into the input box
    > and would like to test this and if not ten digits, then they must
    > re-enter.
    > Could somebody please help me with this, im sure simple code.
    >
    > thanks in advance
    >
    > Tempy
    >
    > *** Sent via Developersdex http://www.developersdex.com ***
    >


  2. #2
    David
    Guest

    RE: Check on the input in an inputbox

    Hi,
    Try this, hope it works for your purposes
    Sub Macro1()
    Dim Message, Title, MyValue
    Message = "Please enter the 10 digit number"
    Title = "10 digit number"
    MyValue = InputBox(Message, Title)
    If MyValue Like "##########" Then
    'Do nothing
    Else
    Stop
    Dim Msg1
    Msg1 = "Please reenter a 10 digit number"
    Response = MsgBox(Msg1)
    End
    End If
    End Sub

    Thanks,

    "Neil" wrote:

    > Put your number in to string variable eg A$
    >
    > Use the following code to test the length of the string
    >
    > If Len(A$) <>10 Then
    > MsgBox ("Incorrect number")
    > 'Do something else to make your user re-enter the number
    > End If
    >
    > Once added to your code the user will only be able to proceed when the
    > variable is ten characters long. Note - this will only check for string
    > length not validity, so letters and numbers can both be used, you will need
    > to add seperate validation for those.
    >
    > HTH
    >
    > Neil
    > www.nwarwick.co.uk
    >
    > "Tempy" wrote:
    >
    > > Good day,
    > > I am requesting the user to enter a ten digit number into the input box
    > > and would like to test this and if not ten digits, then they must
    > > re-enter.
    > > Could somebody please help me with this, im sure simple code.
    > >
    > > thanks in advance
    > >
    > > Tempy
    > >
    > > *** Sent via Developersdex http://www.developersdex.com ***
    > >


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1