dumou8343

Need help to handle some combo

3 posts in this topic

Hey guys,

I'm currently working on this little program that helps people at my work make IT requests, everything is working nice and pollished except for one error handelling I can't seem to figure out.

 

I have 2 combo box

 
    $CBDebut = GUICtrlCreateCombo("", 312, 112, 137, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL))
    GUICtrlSetData(-1, "8:00|8:30|9:00|9:30|10:00|10:30|11:00|11:30|12:00|12:30|13:00|13:30|14:00|14:30|15:00|15:30|16:00|16:30|17:00|17:30", "8:00")
    $CBFin = GUICtrlCreateCombo("", 312, 176, 137, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL))
    GUICtrlSetData(-1, "8:00|8:30|9:00|9:30|10:00|10:30|11:00|11:30|12:00|12:30|13:00|13:30|14:00|14:30|15:00|15:30|16:00|16:30|17:00|17:30", "12:00")

So the goal with this is people can reserve our conference rooms, but If they select 10:00 on $CBDebut and 9:00 on $CBFin it sould give me an error since they can only schedule the room for 1 day at a time, so I need to make sure that the first combo is always smaller then the second one. but since its not numerical value I can't figure it out.

 

If the :30 cauz a problem I could remove them, but I would like for it to say.

 

Thank you guys for the help!

Share this post


Link to post
Share on other sites



dumous8343,

I would do something like this:

#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

#include <GuiComboBox.au3>

$sList = "8:00|8:30|9:00|9:30|10:00|10:30|11:00|11:30|12:00|12:30|13:00|13:30|14:00|14:30|15:00|15:30|16:00|16:30|17:00|17:30"

$hGUI = GUICreate("Test", 500, 500)

$CBDebut = GUICtrlCreateCombo("", 10, 10, 137, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL))
GUICtrlSetData(-1, $sList, "8:00")
$CBFin = GUICtrlCreateCombo("", 10, 50, 137, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL))
GUICtrlSetData(-1, $sList, "12:00")

$cRead = GUICtrlCreateButton("Read", 10, 100, 80, 30)

GUISetState()

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $cRead
            $iIndex_Debut = _GUICtrlComboBox_FindString($CBDebut, GUICtrlRead($CBDebut))
            $iIndex_Fin = _GUICtrlComboBox_FindString($CBFin, GUICtrlRead($CBFin))

            If $iIndex_Debut < $iIndex_Fin Then
                MsgBox($MB_SYSTEMMODAL, "Booking", "Accepted")
            Else
                MsgBox($MB_SYSTEMMODAL, "Error", "End must be after start")
            EndIf
    EndSwitch

WEnd

As long as the 2 combos have identical contents this will work.

M23

1 person likes this

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

Share this post


Link to post
Share on other sites

Wow this works perfectly! Thank you very much I will modify it to fit my needs! you are a superhero! good weekend to you.

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