Jump to content

Recommended Posts

Posted

Hey everyone. I'm working on a little project, and I have run into 2 problems.

Firstly, I need a way to make double digit numbers. Allow me to explain. I have 9 buttons, and each has a number (1-9) on it. When the user clicks on 1 of them, I need it to be put into a variable, but also, when they click on 2 in a row (say the click 1,1) I want it to be read as 11. I need help on how to do this.

Secondly, I have an input box (GuiCtrlCreateInput) on my GUI, and I need it to be updated with a new character everytime someone pushes a button on my GUI.

Any help is appreciated :)

Coder's Helper >> Here[center][/center]

Posted

For your double digit problem, perhaps you can try something like this:

Dim $Variable = "1"
$Variable &= "1"
MsgBox(0, "", $Variable)

As for updating the label, you can try adding some code to update the label after your button code.

Posted

Have no fear. WeaponX is here.

#include <GUIConstants.au3>

GUICreate("My GUI", 200, 200)  ; will create a dialog box that when displayed is centered
GUISetState (@SW_SHOW)       ; will display an empty dialog box

Dim $btnArray[9]

$input = GUICtrlCreateInput ( "", 40, 5, 120)

$num = 0
For $Y = 1 to 3
    For $X = 1 to 3
        $btnArray[$num] = GUICtrlCreateButton ( $num + 1, $X * 40, $Y * 40, 40, 40)
        $num += 1
    Next
Next

Func update($num)
    $currentnum = GuiCtrlRead($input)
    If $currentnum >= 10 Then
        GuiCtrlSetData($input,$num)
    Else
        GuiCtrlSetData($input,$currentnum & $num)
    EndIf
EndFunc

; Run the GUI until the dialog is closed
While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $btnArray[0]
            update(1)
        Case $btnArray[1]
            update(2)
        Case $btnArray[2]
            update(3)
        Case $btnArray[3]
            update(4)
        Case $btnArray[4]
            update(5)
        Case $btnArray[5]
            update(6)
        Case $btnArray[6]
            update(7)
        Case $btnArray[7]
            update(8)
        Case $btnArray[8]
            update(9)
    EndSwitch
    
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Wend

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
×
×
  • Create New...