Jump to content

GUICtrlRead question


shanafelt
 Share

Recommended Posts

I've written a program to take language codes and put them on a subject line of an email. The language codes are set from a combo box.

AL

FR

SP

GR

To read the language code selected, I've been using GUICtrlRead($LangCombo).

I have a request to take the drop down and put in the language in the drop down like this.

AL - Albanian

FR - French

SP - Spanish

GR - Greek

However, when I read the value selected using GUICtrlRead I want to strip off the value except for the first two letters so even though AL - Albanian is in the drop down that is selected, AL is the value passed.

How do I do this? I have been trying things like

$var = GUICtrlRead($LangCombo)

$var2 = StringLeft($var, 2)

Any help would be greatly appreciated.

But no success.

Link to comment
Share on other sites

Could you post the code that populates $LangCombo?

CODE
$LangCombo = GUICtrlCreateCombo("", 50, 230, 100, 20)

GUICtrlSetData($LangCombo, "AL|AI|SL|AM|AR|AE|BN|BK|BO|BR|BL|BS|CA|CN|CB|CM|CR|CH|CC|CZ|DN|DA|DU|EN|ES|FA|FJ|FI|FR|FC|GN|GE

|GR|GJ|HC|HK|HI|HM|HU|IB|IL|IO|IN|IT|JA|KY|KM|KO|KU|LA|LP|LV|LT|MC|MM|ML|MA|MR|MS|MI|NO|OM|OT|PA|PE|

PO|PG|PJ|PU|QU|RO|SH|SA|SN|SV|SM|SP|SD|SI|SW|TA|TM|TH|TB|TI|TS|TN|TR|TK|UK|UN|UR|VI|VS|YA|YR|YU|ZU")

Link to comment
Share on other sites

What I would like to do is add the full name of the language in the combo box like below... but then only have AL or AI passed a value.

CODE
<$LangCombo = GUICtrlCreateCombo("", 50, 230, 100, 20)

GUICtrlSetData($LangCombo, "Albanian - AL|American Indian - AI|SL|AM|AR|AE|BN|BK|BO|BR|BL|BS|CA|CN|CB|CM|CR|CH|CC|CZ|DN|DA|DU|EN|ES|FA|FJ|FI|FR|FC|GN|GE

|GR|GJ|HC|HK|HI|HM|HU|IB|IL|IO|IN|IT|JA|KY|KM|KO|KU|LA|LP|LV|LT|MC|MM|ML|MA|MR|MS|MI|NO|OM|OT|PA|PE|

PO|PG|PJ|PU|QU|RO|SH|SA|SN|SV|SM|SP|SD|SI|SW|TA|TM|TH|TB|TI|TS|TN|TR|TK|UK|UN|UR|VI|VS|YA|YR|YU|ZU")

Thank you for any help.

Link to comment
Share on other sites

  • Moderators

shanafelt,

In your original post you used: AL - Albanian. In your last post you used: Albanian - AL.

For the first you need StringLeft("variable", 2) to get the 2-letter code, for the second StringRight("variable", 2).

Does this solve your problem?

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
Share on other sites

shanafelt,

In your original post you used: AL - Albanian. In your last post you used: Albanian - AL.

For the first you need StringLeft("variable", 2) to get the 2-letter code, for the second StringRight("variable", 2).

Does this solve your problem?

M23

No, I still have the same problem. Sorry about the confusion. I want to use AL - Albanian as the format.

Here is what I'm trying to do.

$var = GUICtrlRead($LangCombo)

$var2 = StringLeft($var, 2)

I want to manipulate the output of GUICtrlRead($LangCombo)

The first line doesn't seem to read the real value of GUICtrlRead($LangCombo) while it outputs correctly

Link to comment
Share on other sites

I don't see the issue here. :P

#include <GUIConstants.au3>

$Main = GuiCreate("Main GUI", 400, 400, -1, -1)
$LangCombo = GUICtrlCreateCombo("", 50, 230, 100, 20)
GUICtrlSetData($LangCombo, "AD - Andorra|AE - United Arab Emirates|AF - Afghanistan|AG - Antigua And Barbuda|AI - Anguilla|AL - Albania|AM - Armenia|AN - Netherlands Antilles|AO - Angola -|AR - Argentina|AS - American Samoa|AT - Austria|AU - Australia|AW - Aruba -|AX - Åland Islands|AZ - Azerbaijan|BA - Bosnia And Herzegovina|BB - Barbados|BD - Bangladesh|BE - Belgium|BF - Burkina Faso|BG - Bulgaria|BH - Bahrain|BI - Burundi|BJ - Benin -|BM - Bermuda|BN - Brunei Darussalam|BO - Bolivia|BR - Brazil -|BS - Bahamas|BT - Bhutan -|BW - Botswana|BY - Belarus|BZ - Belize -|CA - Canada -|CC - Cocos (Keeling) Islands|CD - Congo, The Democratic Republic Of The|CF - Central African Republic|CG - Congo -|CH - Switzerland|CI - Côte D'ivoire|CK - Cook Islands|CL - Chile -|CM - Cameroon|CN - China -|CO - Colombia|CR - Costa Rica|CS - Serbia And Montenegro|CU - Cuba - es|CV - Cape Verde|CX - Christmas Island|CY - Cyprus -|CZ - Czech Republic|DE - Germany|DJ - Djibouti|DK - Denmark|DM - Dominica|DO - Dominican Republic|DZ - Algeria|EC - Ecuador|EE - Estonia|EG - Egypt -|ER - Eritrea|ES - Spain -|ET - Ethiopia|FI - Finland|FJ - Fiji - en|FK - Falkland Islands (Malvinas)|FM - Micronesia, Federated States Of|FO - Faroe Islands|FR - France -|GA - Gabon -|GB - United Kingdom|GD - Grenada|GE - Georgia|GF - French Guiana|GH - Ghana -|GI - Gibraltar|GL - Greenland|GM - Gambia -|GN - Guinea -|GP - Guadeloupe|GQ - Equatorial Guinea|GR - Greece -|GT - Guatemala|GU - Guam - ch|GW - Guinea-Bissau|GY - Guyana -|HK - Hong Kong|HN - Honduras|HR - Croatia|HT - Haiti -|HU - Hungary|ID - Indonesia|IE - Ireland|IL - Israel -|IN - India -|IO - British Indian Ocean Territory|IQ - Iraq - ar|IR - Iran, Islamic Republic Of|IS - Iceland|IT - Italy -|JM - Jamaica|JO - Jordan -|JP - Japan -|KE - Kenya -|KG - Kyrgyzstan|KH - Cambodia|KI - Kiribati|KM - Comoros|KN - Saint Kitts And Nevis|KP - Korea, Democratic People's Republic Of|KR - Korea, Republic Of|KW - Kuwait -|KY - Cayman Islands|KZ - Kazakhstan|LA - Lao People's Democratic Republic|LB - Lebanon|LC - Saint Lucia|LI - Liechtenstein|LK - Sri Lanka|LR - Liberia|LS - Lesotho|LT - Lithuania|LU - Luxembourg|LV - Latvia -|LY - Libyan Arab Jamahiriya|MA - Morocco|MC - Monaco -|MD - Moldova, Republic Of|MG - Madagascar|MH - Marshall Islands|MK - Macedonia, The Former Yugoslav Republic Of|ML - Mali - bm|MM - Myanmar|MN - Mongolia|MO - Macao -|MP - Northern Mariana Islands|MQ - Martinique|MR - Mauritania|MS - Montserrat|MT - Malta -|MU - Mauritius|MV - Maldives|MW - Malawi -|MX - Mexico -|MY - Malaysia|MZ - Mozambique|NA - Namibia|NC - New Caledonia|NE - Niger -|NF - Norfolk Island|NG - Nigeria|NI - Nicaragua|NL - Netherlands|NO - Norway -|NP - Nepal -|NR - Nauru -|NU - Niue - en|NZ - New Zealand|OM - Oman - ar|PA - Panama -|PE - Peru - ay|PF - French Polynesia|PG - Papua New Guinea|PH - Philippines|PK - Pakistan|PL - Poland -|PM - Saint Pierre And Miquelon|PN - Pitcairn|PR - Puerto Rico|PS - Palestinian Territory, Occupied|PT - Portugal|PW - Palau -|PY - Paraguay|QA - Qatar -|RE - Réunion|RO - Romania|RU - Russian Federation|RW - Rwanda -|SA - Saudi Arabia|SB - Solomon Islands|SC - Seychelles|SD - Sudan -|SE - Sweden -|SG - Singapore|SH - Saint Helena|SI - Slovenia|SK - Slovakia|SL - Sierra Leone|SM - San Marino|SN - Senegal|SO - Somalia|SR - Suriname|ST - Sao Tome And Principe|SV - El Salvador|SY - Syrian Arab Republic|SZ - Swaziland|TC - Turks And Caicos Islands|TD - Chad - ar|TG - Togo - ee|TH - Thailand|TJ - Tajikistan|TK - Tokelau|TL - Timor-Leste|TM - Turkmenistan|TN - Tunisia|TO - Tonga -|TR - Turkey -|TT - Trinidad And Tobago|TV - Tuvalu -|TW - Taiwan, Province Of China|TZ - Tanzania, United Republic Of|UA - Ukraine|UG - Uganda -|UM - United States Minor Outlying Islands|US - United States|UY - Uruguay|UZ - Uzbekistan|VA - Holy See (Vatican City State)|VC - Saint Vincent And The Grenadines|VE - Venezuela|VG - Virgin Islands, British|VI - Virgin Islands, U.S.|VN - Viet Nam|VU - Vanuatu|WF - Wallis And Futuna|WS - Samoa -|YE - Yemen -|YT - Mayotte|YU - Yugoslavia|ZA - South Africa|ZM - Zambia -|ZW - Zimbabwe")
GUISetState()
While 1
    $msg = GUIGetMsg()
    Switch $msg
    Case $GUI_EVENT_CLOSE
           ExitLoop
    Case $LangCombo
         $var = GUICtrlRead($LangCombo)
                 $var2 = StringLeft($var, 2)
                 Msgbox(0, "Selection in Language ComboBox", "You Selected " & $var & @CRLF & @CRLF & "Code = " & $var2)
   EndSwitch
Wend
Link to comment
Share on other sites

I don't see the issue here. :P

#include <GUIConstants.au3>

$Main = GuiCreate("Main GUI", 400, 400, -1, -1)
$LangCombo = GUICtrlCreateCombo("", 50, 230, 100, 20)
GUICtrlSetData($LangCombo, "AD - Andorra|AE - United Arab Emirates|AF - Afghanistan|AG - Antigua And Barbuda|AI - Anguilla|AL - Albania|AM - Armenia|AN - Netherlands Antilles|AO - Angola -|AR - Argentina|AS - American Samoa|AT - Austria|AU - Australia|AW - Aruba -|AX - Åland Islands|AZ - Azerbaijan|BA - Bosnia And Herzegovina|BB - Barbados|BD - Bangladesh|BE - Belgium|BF - Burkina Faso|BG - Bulgaria|BH - Bahrain|BI - Burundi|BJ - Benin -|BM - Bermuda|BN - Brunei Darussalam|BO - Bolivia|BR - Brazil -|BS - Bahamas|BT - Bhutan -|BW - Botswana|BY - Belarus|BZ - Belize -|CA - Canada -|CC - Cocos (Keeling) Islands|CD - Congo, The Democratic Republic Of The|CF - Central African Republic|CG - Congo -|CH - Switzerland|CI - Côte D'ivoire|CK - Cook Islands|CL - Chile -|CM - Cameroon|CN - China -|CO - Colombia|CR - Costa Rica|CS - Serbia And Montenegro|CU - Cuba - es|CV - Cape Verde|CX - Christmas Island|CY - Cyprus -|CZ - Czech Republic|DE - Germany|DJ - Djibouti|DK - Denmark|DM - Dominica|DO - Dominican Republic|DZ - Algeria|EC - Ecuador|EE - Estonia|EG - Egypt -|ER - Eritrea|ES - Spain -|ET - Ethiopia|FI - Finland|FJ - Fiji - en|FK - Falkland Islands (Malvinas)|FM - Micronesia, Federated States Of|FO - Faroe Islands|FR - France -|GA - Gabon -|GB - United Kingdom|GD - Grenada|GE - Georgia|GF - French Guiana|GH - Ghana -|GI - Gibraltar|GL - Greenland|GM - Gambia -|GN - Guinea -|GP - Guadeloupe|GQ - Equatorial Guinea|GR - Greece -|GT - Guatemala|GU - Guam - ch|GW - Guinea-Bissau|GY - Guyana -|HK - Hong Kong|HN - Honduras|HR - Croatia|HT - Haiti -|HU - Hungary|ID - Indonesia|IE - Ireland|IL - Israel -|IN - India -|IO - British Indian Ocean Territory|IQ - Iraq - ar|IR - Iran, Islamic Republic Of|IS - Iceland|IT - Italy -|JM - Jamaica|JO - Jordan -|JP - Japan -|KE - Kenya -|KG - Kyrgyzstan|KH - Cambodia|KI - Kiribati|KM - Comoros|KN - Saint Kitts And Nevis|KP - Korea, Democratic People's Republic Of|KR - Korea, Republic Of|KW - Kuwait -|KY - Cayman Islands|KZ - Kazakhstan|LA - Lao People's Democratic Republic|LB - Lebanon|LC - Saint Lucia|LI - Liechtenstein|LK - Sri Lanka|LR - Liberia|LS - Lesotho|LT - Lithuania|LU - Luxembourg|LV - Latvia -|LY - Libyan Arab Jamahiriya|MA - Morocco|MC - Monaco -|MD - Moldova, Republic Of|MG - Madagascar|MH - Marshall Islands|MK - Macedonia, The Former Yugoslav Republic Of|ML - Mali - bm|MM - Myanmar|MN - Mongolia|MO - Macao -|MP - Northern Mariana Islands|MQ - Martinique|MR - Mauritania|MS - Montserrat|MT - Malta -|MU - Mauritius|MV - Maldives|MW - Malawi -|MX - Mexico -|MY - Malaysia|MZ - Mozambique|NA - Namibia|NC - New Caledonia|NE - Niger -|NF - Norfolk Island|NG - Nigeria|NI - Nicaragua|NL - Netherlands|NO - Norway -|NP - Nepal -|NR - Nauru -|NU - Niue - en|NZ - New Zealand|OM - Oman - ar|PA - Panama -|PE - Peru - ay|PF - French Polynesia|PG - Papua New Guinea|PH - Philippines|PK - Pakistan|PL - Poland -|PM - Saint Pierre And Miquelon|PN - Pitcairn|PR - Puerto Rico|PS - Palestinian Territory, Occupied|PT - Portugal|PW - Palau -|PY - Paraguay|QA - Qatar -|RE - Réunion|RO - Romania|RU - Russian Federation|RW - Rwanda -|SA - Saudi Arabia|SB - Solomon Islands|SC - Seychelles|SD - Sudan -|SE - Sweden -|SG - Singapore|SH - Saint Helena|SI - Slovenia|SK - Slovakia|SL - Sierra Leone|SM - San Marino|SN - Senegal|SO - Somalia|SR - Suriname|ST - Sao Tome And Principe|SV - El Salvador|SY - Syrian Arab Republic|SZ - Swaziland|TC - Turks And Caicos Islands|TD - Chad - ar|TG - Togo - ee|TH - Thailand|TJ - Tajikistan|TK - Tokelau|TL - Timor-Leste|TM - Turkmenistan|TN - Tunisia|TO - Tonga -|TR - Turkey -|TT - Trinidad And Tobago|TV - Tuvalu -|TW - Taiwan, Province Of China|TZ - Tanzania, United Republic Of|UA - Ukraine|UG - Uganda -|UM - United States Minor Outlying Islands|US - United States|UY - Uruguay|UZ - Uzbekistan|VA - Holy See (Vatican City State)|VC - Saint Vincent And The Grenadines|VE - Venezuela|VG - Virgin Islands, British|VI - Virgin Islands, U.S.|VN - Viet Nam|VU - Vanuatu|WF - Wallis And Futuna|WS - Samoa -|YE - Yemen -|YT - Mayotte|YU - Yugoslavia|ZA - South Africa|ZM - Zambia -|ZW - Zimbabwe")
GUISetState()
While 1
    $msg = GUIGetMsg()
    Switch $msg
    Case $GUI_EVENT_CLOSE
           ExitLoop
    Case $LangCombo
         $var = GUICtrlRead($LangCombo)
                 $var2 = StringLeft($var, 2)
                 Msgbox(0, "Selection in Language ComboBox", "You Selected " & $var & @CRLF & @CRLF & "Code = " & $var2)
   EndSwitch
Wend
Thank you! I was putting trying to assign the variable and use the StringLeft function outside of the While loop. Good example by the way... I'm very impressed! :-)
Link to comment
Share on other sites

Welcome. Do take the time to pre-pend a "Solved" to this thread title.

Thank you! I was putting trying to assign the variable and use the StringLeft function outside of the While loop. Good example by the way... I'm very impressed! :-)

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