Sign in to follow this  
Followers 0
ZenKensei

Quick syntax question for combo box

5 posts in this topic

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

Share this post


Link to post
Share on other sites



#2 ·  Posted (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 by flyingboz

Reading the help file before you post... Not only will it make you look smarter, it will make you smarter.

Share this post


Link to post
Share on other sites

Does this work for you ? _GUICtrlListInsertItem


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

 

WindowsError.gif

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

Share this post


Link to post
Share on other sites

#4 ·  Posted (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 by NegativeNrG

[size=20]My File Upload[/size]Register at my site and upload.

Share this post


Link to post
Share on other sites

#5 ·  Posted (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)
EndFunc
I'm not sure if StringFormat() will require Beta or not... Edited by SmOke_N

[center]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.[/center]

Share this post


Link to post
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
Sign in to follow this  
Followers 0