Jump to content

Combo Box - First Option Only


Recommended Posts

The following portion of script works fine within my script but when I select the second or third option from the combo box only the first option (date only) is executed. Everything looks right to me, but of course I am overlooking something. What am I missing? Thank you.

$DateOptions = GuiCtrlCreatecombo("", 140, 150)
GUICtrlSetData(-1,"Date Only|Date With Comment|Comment Only","Date Only") 

GUISetState ()

$msg = 0
While $msg <> $GUI_EVENT_CLOSE
       $msg = GUIGetMsg()
       Select

   Case $msg = $btn
       
       $optionwrite =""
       
                    if $DateOptions == "Date Only" Then
                    $optionwrite = $optionwrite & " -datefmt %b-%d-%Y " 
                    EndIf
                
                    if $DateOptions == "Date With Comment" Then
                    $optionwrite = $optionwrite & " -datefmt @C:%b-%d-%Y "  
                    EndIf

                    if $DateOptions == "Comment Only" Then
                    $optionwrite = $optionwrite & " -datefmt @C "   
                    EndIf
Link to comment
Share on other sites

The following portion of script works fine within my script but when I select the second or third option from the combo box only the first option (date only) is executed. Everything looks right to me, but of course I am overlooking something. What am I missing? Thank you.

You need to read the value from the combo, not just check the Control ID number:

#include <GuiConstants.au3>

$hGUI = GUICreate("Test", 160, 150)
$DateOptions = GUICtrlCreateCombo("", 10, 10, 140, 150)
GUICtrlSetData(-1, "Date Only|Date With Comment|Comment Only", "Date Only")
$btn = GUICtrlCreateButton("GO", 40, 100, 60, 30)
GUISetState()

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $btn
            $optionwrite = ""
            If GUICtrlRead($DateOptions) == "Date Only"  Then
                $optionwrite = $optionwrite & " -datefmt %b-%d-%Y "
                MsgBox(64, "Test", "Debug: $optionwrite = " & $optionwrite)
            EndIf

            If GUICtrlRead($DateOptions) == "Date With Comment"  Then
                $optionwrite = $optionwrite & " -datefmt @C:%b-%d-%Y "
                MsgBox(64, "Test", "Debug: $optionwrite = " & $optionwrite)
            EndIf

            If GUICtrlRead($DateOptions) == "Comment Only"  Then
                $optionwrite = $optionwrite & " -datefmt @C "
                MsgBox(64, "Test", "Debug: $optionwrite = " & $optionwrite)
            EndIf
            ; ...
    EndSelect
    ; ...
WEnd

:)

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
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...