ZenKensei Posted March 13, 2006 Share Posted March 13, 2006 Group, This is probably pretty quick but I've tried a couple of different pieces of code with no success. I'm looking to create a combo box in a gui and I want it to display a list of numbers, specifically 001 through 100 (using all 3 digits to display). Obviously I could do this the long way and actually add each number such as: GUICtrlSetData(-1, "001|002|003|004") etc. until I get to 100. But i'm sure there should be something similar to: for $i = 001 to 100 but I have not been able to get this to work. hope this makes sense... any help would be appreciated. Thanks ZenKensei Link to comment Share on other sites More sharing options...
flyingboz Posted March 13, 2006 Share Posted March 13, 2006 (edited) I want it to display a list of numbers, specifically 001 through 100 (using all 3 digits to display).;Look up IncrementStringAsNum , that and concatenation should do the trick. Edited March 13, 2006 by flyingboz Reading the help file before you post... Not only will it make you look smarter, it will make you smarter. Link to comment Share on other sites More sharing options...
nitekram Posted March 13, 2006 Share Posted March 13, 2006 Does this work for you ? _GUICtrlListInsertItem 2¢ All by me:"Sometimes you have to go back to where you started, to get to where you want to go." "Everybody catches up with everyone, eventually" "As you teach others, you are really teaching yourself." From my dad "Do not worry about yesterday, as the only thing that you can control is tomorrow." WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2 AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit Docs SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language Programming Tips Excel Changes ControlHover.UDF GDI_Plus Draw_On_Screen GDI Basics GDI_More_Basics GDI Rotate GDI Graph GDI CheckExistingItems GDI Trajectory Replace $ghGDIPDll with $__g_hGDIPDll DLL 101? Array via Object GDI Swimlane GDI Plus French 101 Site GDI Examples UEZ GDI Basic Clock GDI Detection Ternary operator Link to comment Share on other sites More sharing options...
NegativeNrG Posted March 13, 2006 Share Posted March 13, 2006 (edited) For $additem = 001 to 100 if $additem < 010 Then GUictrlsetdata($Combo1,'00' & $additem) Endif if $additem > 09 Then GUIctrlsetdata($Combo1,'0' & $additem) Endif if $additem > 099 Then GUIctrlsetdata($Combo1,$additem) EndIf Replace $Combo1 with your name, it also adds 0100 to it, don't know why. Edited March 13, 2006 by NegativeNrG [size=20]My File Upload[/size]Register at my site and upload. Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted March 13, 2006 Moderators Share Posted March 13, 2006 (edited) For $additem = 001 to 100 if $additem < 010 Then GUictrlsetdata($Combo1,'00' & $additem) Endif if $additem > 09 Then GUIctrlsetdata($Combo1,'0' & $additem) Endif if $additem > 099 Then GUIctrlsetdata($Combo1,$additem) EndIf Replace $Combo1 with your name, it also adds 0100 to it, don't know why.Or : For $additem = 1 to 100 $Replace = StringReplace(StringFormat('%3g', $additem), ' ', '0') MsgBox(0, '', $Replace) Next The forum was quiet, so I thought I'd give an example of it in action:#include <GUICONSTANTS.AU3> $MainGui = GUICreate('ComboTest') $Combo = GUICtrlCreateCombo('Choose Number', 10, 10, 200, 100) GUICtrlSetData($Combo, _ComboInsertNum(1000, 3), 'Choose Number'); 1000 and 3 are optional, just used to show you you could change it... You could use _ComboInsertNum() just like that.. if you wish GUISetState() While 1 $msg = GUIGetMsg() If $msg = - 3 Then Exit WEnd Func _ComboInsertNum($i_Count = '100', $i_LeadingZeros = '3') Local $i_Data = '' For $i = 1 to $i_Count $i_Data = $i_Data & StringReplace(StringFormat('%' & $i_LeadingZeros & 'g', $i), ' ', '0') & '|' Next Return StringTrimRight($i_Data, 1) EndFuncI'm not sure if StringFormat() will require Beta or not... Edited March 13, 2006 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
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