shanafelt Posted February 26, 2009 Posted February 26, 2009 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.
DaRam Posted February 26, 2009 Posted February 26, 2009 Could you post the code that populates $LangCombo?
shanafelt Posted February 26, 2009 Author Posted February 26, 2009 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")
shanafelt Posted February 26, 2009 Author Posted February 26, 2009 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.
Moderators Melba23 Posted February 26, 2009 Moderators Posted February 26, 2009 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 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
shanafelt Posted February 26, 2009 Author Posted February 26, 2009 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?M23No, 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
MyName Posted February 26, 2009 Posted February 26, 2009 Try This #Include <GuiComboBox.au3> $var = _GUICtrlComboBox_GetEditText($LangCombo) -= [font="Verdana"]A Men Who believes in himself and not circumstances is the real Winner =-[/font]
DaRam Posted February 26, 2009 Posted February 26, 2009 I don't see the issue here. #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
shanafelt Posted February 26, 2009 Author Posted February 26, 2009 I don't see the issue here. #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! :-)
DaRam Posted February 26, 2009 Posted February 26, 2009 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! :-)
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now