Jump to content

Recommended Posts

Hi All

I've tried looking through the forum and couldn't find the answer. Its really basic but can you set a minimun number of characters to a inputbox? I know you can set a maximun ie

$value = InputBox("Testing", "Enter the 1 or 2 character code.", "", " M2")

any help at all would be appreciated.

Regards

Mark

Link to post
Share on other sites

you are right, as far as I can tell

try this . . .

$bLoop = 1
    While $bLoop = 1
        $Value = InputBox("Test", "Type Atleast three characters and press 'ok'")
        If @error = 1 Then
            $bLoop = 0
        Else
            If StringLen($Value) < 3 Then
                MsgBox(4096, "What were you thinkin?", " . . . I refuse, try again!")
            Else
                $bLoop = 0
            EndIf
        EndIf
    WEnd

Edit: Darn those mvp's! How about a handycap for the little guys! :)

Edited by Hatcheda
Link to post
Share on other sites

...How about a handycap for the little guys! :)

Between my senility and my typing - you should win most of the time :-)

I was working on handling cancel if a range of characters was used and the OP was not able to use StringLen($value) = 5. I came up with pretty much what you did:

While 1
    $value = InputBox("Testing", "Enter the 3 to 5 character code.", "", " M5")
    If @error = 1 Or StringLen($value) > 2 Then
        ExitLoop
    Else
        MsgBox(0, "Error", "Must be 3 to 5 characters.")
    EndIf
WEnd

[size="1"][font="Arial"].[u].[/u][/font][/size]

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...