Jump to content

Converting combo field data once submitted


Recommended Posts

I was just wondering if there was an easier way to do this, without having a million if then's to change the letter to a number, it works, but was just thinking this is a really dumb idea.

#include <GuiConstants.au3>

Opt('GUIOnEventMode', 1)

GuiCreate("test", 279, 50,-1, -1 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS))

$Combo_1 = GuiCtrlCreateCombo("Combo", 10, 10, 160, 21, $CBS_DROPDOWNLIST)
$Button_2 = GuiCtrlCreateButton("Button", 190, 10, 80, 20)

GUICtrlSetData($Combo_1, "|a|b|c|d|")

GUISetOnEvent($GUI_EVENT_CLOSE, 'quit')
GUICtrlSetOnEvent($Button_2, 'buttonfunc')

GuiSetState()
While 1
Sleep(100)
WEnd

Func quit()
Exit
EndFunc

Func buttonfunc()
test1()
MsgBox(0, "Test", & "Test1 = " $test1)
EndFunc

Func test1()
$test1 = GUICtrlRead($Combo_1)
If $test1 = "" then
Global $test1 = "Undefined"
EndIf
If $test1 = "a" then
Global $test1 = "1"
EndIf
If $test1 = "b" then
Global $test1 = "2"
EndIf
If $test1 = "b" then
Global $test1 = "3"
EndIf
If $test1 = "b" then
Global $test1 = "4"
EndIf
EndFunc
Link to comment
Share on other sites

As far as I know this is a bit smaller ;)

Func test1()
Switch GUICtrlRead($Combo_1)
    Case ""
    Global $test1 = "Undefined"
    Case "a"
    Global $test1 = "1"
    Case "b"
    Global $test1 = "2"
    Case "c"
    Global $test1 = "3"
    Case "d"
    Global $test1 = "4"
EndSwitch
EndFunc

But I don't know how it could be made smaller...

Neo

Edited by NeoFoX

[center][font="Arial"]--- The Neo and Only --- [/font][font="Arial"]--Projects---[/font]Image to Text converterText to ASCII converter[/center]

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...