Jump to content
Sign in to follow this  
Elephant007

[Solved] Required number of digits check

Recommended Posts

Elephant007

I am stuck on trying to figure this one out. I have search with no success

Basically I have a GUICtrlCreateInput which I need to be read to make sure is has 4 digits in it before the script will continue

$InputBox = GUICtrlCreateInput ('', 10, 10, 100, 20 )
GUICtrlSetLimit ($InputBox, 4, 4 )

$Accept = GUICtrlCreateRadio('Accept', 20, 20, 100, 20 )

While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
ExitLoop
Case $Accept
If GUICtrlRead($Input) ????? Then....

The inputbox must contain 4 digits, it doesn't matter if the a letters or numbers (no special characters would be nice to prevent too)

If someone could give me good direction on how I can check to ensure the box has 4 digits, I can do the rest...

Thank you in advance for all your help

Edited by Elephant007

Share this post


Link to post
Share on other sites
somdcomputerguy

Try the StringLen() function.


- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Share this post


Link to post
Share on other sites
stormbreaker

If StringLen(GUICtrlRead($Input)) = 4 Then DoSomething()

Perhaps...

REASON FOR EDIT: Perhaps a bad practice to use quotes (as Smoke_N pointed out)

Edited by MKISH

----------------------------------------

:bye: Hey there, was I helpful?

----------------------------------------

My Current OS: Win8 PRO (64-bit); Current AutoIt Version: v3.3.8.1

Share this post


Link to post
Share on other sites
SmOke_N

Geeze, your request is so confusing ( 4 digits ... then you say ... doesn't matter if it has regular characters or numbers ), last I checked, a digit was a number?

- removed stringlen() suggestion comment because I re-read request

Or, just use regex if your request is really "At Least 4 Numbers":

; at least 4digits and any other characters
If StringRegExp(GUICtrlRead($Input), "d{4}") Then
; etc etc and so on
Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites
Elephant007

I guess I should have been clearer

I mean alpha-numeric... doesn't matter if it's 0-9 or A-Z or a combination of both, I used digit incorrectly, I apologize

With the help that I received I was able to use this to solve my issue

If StringLen(GUICtrlRead($Input)) < 4 Then MsgBox(0,'', 'Less Than 4')

I appreciate everyone's speedy suggestions

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  

×