Sign in to follow this  
Followers 0
deef99

How to allow a set number of digits for GUICtrlCreateInput

9 posts in this topic

Hello All,

Just started this script to have a user enter only 10 digit numbers into the Input Box. Got it so that they can only enter digits, but how do I only allow 10 digits? Can't figure it out!

#include "File.au3"

#include "String.au3"

#include <GUIConstantsEx.au3>

$file = ""

$foo = ""

Example()

Func Example()

Local $file, $btn, $msg

GUICreate("Block Number:", 180, 60, @DesktopWidth / 2 - 160, @DesktopHeight / 2 - 45, -1, 0x00000018)

$file = GUICtrlCreateInput("", 12, 5, 100, 20,0x2000)

$btn = GUICtrlCreateButton("Post", 130, 12, 40, 20)

GUISetState()

$msg = 0

While $msg <> $GUI_EVENT_CLOSE

$msg = GUIGetMsg()

Select

Case $msg = $btn

$foo = GUICtrlRead($file)

ExitLoop

EndSelect

WEnd

Exit

EndFunc ;==>Example

Share this post


Link to post
Share on other sites



deef99,

Try looking at GUICtrlSetLimit in the Help file. :mellow:

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Duh!!!!! I knew it had to be somewhere...just didn't know where!

Thank you for the SUPER FAST REPLY!!!!

Share this post


Link to post
Share on other sites

Hummmm..........

No matter where I put the statement: GUICtrlSetLimit(-1,10,10) it still lets me enter less/more than 10.

A quandry...

Share this post


Link to post
Share on other sites

deef99,

The limit for an input only applies to the MAX, you have to test for the MIN yourself: :mellow:

#include <GUIConstantsEx.au3>

$hGUI = GUICreate("Test", 500, 500)

$hInput = GUICtrlCreateInput("", 10, 10, 100, 20)
GUICtrlSetLimit(-1, 10, 10)

$hButton = GUICtrlCreateButton("Read", 10, 100, 80, 30)

GUISetState()

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $hButton
            If StringLen(GUICtrlRead($hInput)) = 10 Then
                MsgBox(0, "", "You entered 10 numbers")
            Else ; We have less than 10
                MsgBox(0, "", "Please enter at least 10 numbers")
            EndIf
            ; No need to test for more because GUICtrlSetLimit does that for us
    EndSwitch

WEnd

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Ok...got that...one more question and I am out of your hair...

If they do NOT enter 10, and they can a Msgbox stating to enter 10...how do I reinvoke the Input Box?

Sorry...very new to this gui stuff....

D

Share this post


Link to post
Share on other sites

deef99,

As you have not deleted it, it can still be filled. Take a look at this:

#include <GUIConstantsEx.au3>

$hGUI = GUICreate("Test", 500, 500)

$hInput = GUICtrlCreateInput("", 10, 10, 100, 20)
GUICtrlSetLimit(-1, 10, 10)

$hButton = GUICtrlCreateButton("Read", 10, 100, 80, 30)

GUISetState()

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $hButton
            If StringLen(GUICtrlRead($hInput)) = 10 Then
                MsgBox(0, "", "You entered 10 numbers")
                GUICtrlDelete($hInput)
                GUICtrlDelete($hButton)
                GUICtrlCreateLabel("You entered 10 numbers", 10, 10, 200, 20)
            Else ; We have less than 10
                MsgBox(0, "", "Please enter at least 10 numbers")
                GUICtrlSetData($hInput, "")
                GUICtrlSetState($hInput, $GUI_FOCUS)
            EndIf
            ; No need to test for more because GUICtrlSetLimit does that for us
    EndSwitch

WEnd

All clear? Ask if not. :mellow:

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

AWESOME!!!!!!!!!!!!!!!!!!!

Thank you so very very much!

Have a great day!

Share this post


Link to post
Share on other sites

deef99,

Have a great day!

It is actually very near my bed-time - is it alright if I have a great tomorrow instead? :mellow:

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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