Jump to content
Sign in to follow this  
markcheese

Input Box (help)

Recommended Posts

markcheese

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

Share this post


Link to post
Share on other sites
herewasplato

Welcome to the forum.

Try this code:

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

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

Share this post


Link to post
Share on other sites
John117

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

Share this post


Link to post
Share on other sites
herewasplato

...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]

Share this post


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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.