Jump to content
Sign in to follow this  
Phaethon

Two Questions

Recommended Posts

Phaethon

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]

Share this post


Link to post
Share on other sites
Emperor

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.

Share this post


Link to post
Share on other sites
PsaltyDS

It would look something like this:

; Assuming button '5'
GUICtrlSetData($Input_1, GUICtrlRead($Input_1) & '5')

The variable $Input_1 is the control ID of the input.

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites
weaponx

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

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  

×