Sign in to follow this  
Followers 0
markcheese

Input Box (help)

5 posts in this topic

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



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

#3 ·  Posted (edited)

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

Thank you, Thats just what I needed.

Share this post


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]

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  
Followers 0