markcheese Posted December 28, 2007 Share Posted December 28, 2007 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 comment Share on other sites More sharing options...
herewasplato Posted December 28, 2007 Share Posted December 28, 2007 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] Link to comment Share on other sites More sharing options...
John117 Posted December 28, 2007 Share Posted December 28, 2007 (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 December 28, 2007 by Hatcheda Link to comment Share on other sites More sharing options...
markcheese Posted December 28, 2007 Author Share Posted December 28, 2007 Thank you, Thats just what I needed. Link to comment Share on other sites More sharing options...
herewasplato Posted December 28, 2007 Share Posted December 28, 2007 ...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 comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now