Jump to content

Formula Help


Teldin
 Share

Recommended Posts

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

  • 4 weeks later...

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