Sign in to follow this  
Followers 0
Chobyhy

Input Box Return Value

4 posts in this topic

Global $Test

Func _NewAccountForm()
    $NewAcc = GUICtrlCreateInput("Default", 100, 90, 100, 20)
    $AddNewAcc = GUICtrlCreateButton("Add", 100, 115, 50, 20)
    GUICtrlSetOnEvent(-1, "_AddNewAccount")
    $AddNewAccCancle = GUICtrlCreateButton("Cancel", 150, 115, 50, 20)
    GUICtrlSetOnEvent(-1, "_AddNewAccountCancle")
EndFunc

Func _AddNewAccount()
    If Not $NewAcc = "" Then
    $AccountCount = IniRead($IniDir, "Main", "Acc", "0")
    $AccountCount = $AccountCount + 1
    IniWrite($IniDir, "Main", "Account" & $AccountCount, $NewAcc)
    IniWrite($IniDir, "Main", "Acc", $AccountCount)
    EndIf
EndFunc

This is just a part of the code and the problem is that it keeps writing in the Ini that $NewAcc = 14 even though I put in a different value in the inbox. Any suggestion?

Share this post


Link to post
Share on other sites

#2 ·  Posted (edited)

the problem is that you need GuiCtrlRead() to retrieve the value from controls , so try:

Global $Test

Func _NewAccountForm()
    $NewAcc = GUICtrlCreateInput("Default", 100, 90, 100, 20)
    $AddNewAcc = GUICtrlCreateButton("Add", 100, 115, 50, 20)
    GUICtrlSetOnEvent(-1, "_AddNewAccount")
    $AddNewAccCancle = GUICtrlCreateButton("Cancel", 150, 115, 50, 20)
    GUICtrlSetOnEvent(-1, "_AddNewAccountCancle")
EndFunc

Func _AddNewAccount()
    If Not GuiCtrlRead($NewAcc) == "" Then
    $AccountCount = IniRead($IniDir, "Main", "Acc", "0")
    $AccountCount = $AccountCount + 1
    IniWrite($IniDir, "Main", "Account" & $AccountCount, GuiCtrlRead($NewAcc))
    IniWrite($IniDir, "Main", "Acc", $AccountCount)
    EndIf
EndFunc

PS: add GuiCtrlRead() anywere else you are reading from a control

Edited by Gif

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Just for reference, Gif is correct, and what it is returning without reading it first is the ID / handle of the control. You always need to use GUICtrlRead(), unless you specifically want to get the handle.

Edited by sandman

[center]"Yes, [our app] runs on Windows as well as Linux, but if you had a Picasso painting, would you put it in the bathroom?" -BitchX.com (IRC client)"I would change the world, but they won't give me the source code." -Unknownsite . blog . portfolio . claimidcode.is.poetry();[/center]

Share this post


Link to post
Share on other sites

Thanks for the help :)

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