Sign in to follow this  
Followers 0
Teldin

Formula Help

8 posts in this topic

$p_data = GUICtrlCreateCombo("Change This", 70, 230, 430, 30)

GUICtrlSetData($p_data, "data1|data2|data3|data4|data5|data6|data7|data8")

Dim $p_value

If GUICtrlRead($p_data) = "data1" Then

$p_value = 0

ElseIf GUICtrlRead($p_data) = "data2" Then

$p_value = 1

ElseIf GUICtrlRead($p_data) = "data3" Then

$p_value = 2

ElseIf GUICtrlRead($p_data) = "data4" Then

$p_value = 3

ElseIf GUICtrlRead($p_data) = "data5" Then

$p_value = 4

ElseIf GUICtrlRead($p_data) = "data6" Then

$p_value = 5

ElseIf GUICtrlRead($p_data) = "data7" Then

$p_value = 6

ElseIf GUICtrlRead($p_data) = "data8" Then

$p_value = 7

EndIf

GuiCtrlCreateEdit($p_value, 10, 300, 120, 40)

;above line is just to test if the value is correct...

Thanks in advance.

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Welcome to the forums

;$p_data = GUICtrlCreateCombo("Change This", 70, 230, 430, 30)
;GUICtrlSetData($p_data, "data1|data2|data3|data4|data5|data6|data7|data8")
Dim $p_value = -1

For $x = 1 to 8
    If StringInStr(GUICtrlRead($p_data), $x) Then
        $p_value += $x
    EndIf
Next

GuiCtrlCreateEdit($p_value, 10, 300, 120, 40)
;above line is just to test if the value is correct...

8)

Edited by Valuater

NEWHeader1.png

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

I actually posted a couple of times last week before the forums died, but those posts are lost.

Anyways, thanks for the answer Valuater but I do need the user to choose between the "data" options in the combo box ($p_data) then that will determine the numberical value of $p_value. I tried to incorporate your fomula into mind with the combo box with no success. How would I do that?

Edited by Teldin

Share this post


Link to post
Share on other sites

Any ideas? :whistle:

Share this post


Link to post
Share on other sites

Well.. what do you need to happen ??


Start here if you are new Valuater's AutoIT 1-2-3Looking for an UDF - Look hereDo you need to do it twice - Autoit

Share this post


Link to post
Share on other sites

The user selects 1 value ($p_data) choice from the combo box (or can be a radio box if needed) which is turned into a numerical value ($p_value) to be used later in the script.

Share this post


Link to post
Share on other sites

Something like this

#include <GUIConstants.au3>

GUICreate("test", 200, 200)

$p_data = GUICtrlCreateCombo("Change This", 10, 10, 100, 30)
GUICtrlSetData($p_data, "data1|data2|data3|data4|data5|data6|data7|data8")

GUISetState()

do
    $msg = GUIGetMsg()

    IF $msg = $p_data Then
        Select
            Case GUICtrlRead($p_data) = "data1"
                $p_value = 1
            Case GUICtrlRead($p_data) = "data2"
                $p_value = 2
            Case GUICtrlRead($p_data) = "data3"
                $p_value = 3
            Case GUICtrlRead($p_data) = "data4"
                $p_value = 4
            Case GUICtrlRead($p_data) = "data5"
                $p_value = 5
            Case GUICtrlRead($p_data) = "data6"
                $p_value = 6
            Case GUICtrlRead($p_data) = "data7"
                $p_value = 7
            Case GUICtrlRead($p_data) = "data8"
                $p_value = 8
        EndSelect
        MsgBox(0,0,$p_value)
    EndIf

until $msg = $GUI_EVENT_CLOSE

Start here if you are new Valuater's AutoIT 1-2-3Looking for an UDF - Look hereDo you need to do it twice - Autoit

Share this post


Link to post
Share on other sites

I forgot to reply that your solution worked perfectly, thanks Shevilie.

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