Jump to content

How can I get the value of the variable in combobox


NewBie_2018
 Share

Recommended Posts

Hello

Before start asking question, I apologize for my poor english

(So I'm writing this topic using translator :sweating:)

 

This is my question

 

Among many volumes in computer, I want to get the letter of volume.

So I wrote this code

#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <GUIConstantsEx.au3>

Opt("GUIOnEventMode", 1)

$Form1 = GUICreate("title", 291, 246, 184, 261)
GUISetOnEvent($GUI_EVENT_CLOSE, "Exitapp")
$Combo1 = GUICtrlCreateCombo("select volume", 16, 32, 257, 25, 0x0003)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Button1 = GUICtrlCreateButton("Check", 16, 70, 257, 25)
GUICtrlSetOnEvent($Button1, "Func_Check")
GUISetState(@SW_SHOW)

Local $var = DriveGetDrive("All")
If Not @error Then
   For $i = 1 To $var[0]
      $DriveType = DriveGetType($var[$i])


      If $DriveType = "Removable" Or $DriveType = "Fixed" Then
         $letter = StringUpper($var[$i])
         GUICtrlSetData($Combo1, $letter)
      EndIf
   Next
EndIf

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
 WEnd

;;;;;;;;;;;;;;;;;;;;;;;;; UDF Area ;;;;;;;;;;;;;;;;;;;;;;;;;
 Func Func_Check()
    MsgBox(0, "test", $Combo1)
 EndFunc

Func Exitapp()
   Exit
EndFunc

 

but, 

When I click the button, I can see only " 3 " 

According to a lot of topics what i saw, in case using " | ", I can get the value what I want.

But I have no idea how to use " | " in my code. 

If there's a good way I do not know, please let me know.

 

Thank you for reading. Have a good day.

 

Link to comment
Share on other sites

  • Moderators

@NewBie_2018 Welcome to the forum. Try changing this:

MsgBox(0, "test", $Combo1)

To this:

MsgBox(0, "test", GUICtrlRead($Combo1))

See the help file on GUICtrlRead for more info.

Edited by JLogan3o13

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

  • Moderators

It is not a problem, we can move the topic. Did my suggestion fix the issue for you?

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

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