Filling a combobox with decimal numbers 
Author Message
 Filling a combobox with decimal numbers

I am trying to fill 5 comboboxes with decimal numbers.
I have set the comboboxes in a control array from index 1 to 5.

Here's the code i have so far :

        Dim Idx As Integer
        Dim Kmt As Variant

        For Idx = 1 to 5
                For Kmt = 19.1 to 30.1
                        cboKmt(Idx).AddItem (Kmt)
                Next Kmt
        Next Idx

This code doesn't work since i just get the whole number: 19.1 - 20.1 - 21.1 etc.
I want all the numbers from 19.1 to 30.1 : 19.1 - 19.2 - 19.3 etc.

If someone can help me with this, It would be appreciated.

Kris D.



Sun, 24 Dec 2000 03:00:00 GMT  
 Filling a combobox with decimal numbers
Dim Idx As Integer
Dim Kmt As Variant

For Kmt = 19.1 to 30.1 Step 0.1
    For Idx = 1 to 5
        cboKmt(Idx).AddItem Kmt
    Next Idx
Next Kmt

Quote:

>I am trying to fill 5 comboboxes with decimal numbers.
>I have set the comboboxes in a control array from index 1 to 5.

>Here's the code i have so far :

> Dim Idx As Integer
> Dim Kmt As Variant

> For Idx = 1 to 5
> For Kmt = 19.1 to 30.1
> cboKmt(Idx).AddItem (Kmt)
> Next Kmt
> Next Idx

>This code doesn't work since i just get the whole number: 19.1 - 20.1 -
21.1 etc.
>I want all the numbers from 19.1 to 30.1 : 19.1 - 19.2 - 19.3 etc.

>If someone can help me with this, It would be appreciated.

>Kris D.



Sun, 24 Dec 2000 03:00:00 GMT  
 Filling a combobox with decimal numbers

In 'For...Next' statements, the default increment is '1'.

If you want to use anything else, you have to state it using 'Step'.
Your code should look like this...

Dim Idx As Integer
        Dim Kmt As Variant

        For Idx = 1 to 5 Step 0.1
                For Kmt = 19.1 to 30.1
                        cboKmt(Idx).AddItem (Kmt)
                Next Kmt
        Next Idx

Have a look in Help for more details

Mianne

Quote:

> I am trying to fill 5 comboboxes with decimal numbers.
> I have set the comboboxes in a control array from index 1 to 5.

> Here's the code i have so far :

>         Dim Idx As Integer
>         Dim Kmt As Variant

>         For Idx = 1 to 5
>                 For Kmt = 19.1 to 30.1
>                         cboKmt(Idx).AddItem (Kmt)
>                 Next Kmt
>         Next Idx

> This code doesn't work since i just get the whole number: 19.1 - 20.1 - 21.1 etc.
> I want all the numbers from 19.1 to 30.1 : 19.1 - 19.2 - 19.3 etc.

> If someone can help me with this, It would be appreciated.

> Kris D.



Mon, 25 Dec 2000 03:00:00 GMT  
 Filling a combobox with decimal numbers

Sorry, I put the 'Step' in the wrong For...Next loop.

In 'For...Next' statements, the default increment is '1'.

If you want to use anything else, you have to state it using 'Step'.
Your code should look like this...

Dim Idx As Integer
        Dim Kmt As Variant

        For Idx = 1 to 5
                For Kmt = 19.1 to 30.1 Step 0.1
                        cboKmt(Idx).AddItem (Kmt)
                Next Kmt
        Next Idx

Have a look in Help for more details

Mianne

Quote:

> I am trying to fill 5 comboboxes with decimal numbers.
> I have set the comboboxes in a control array from index 1 to 5.

> Here's the code i have so far :

>         Dim Idx As Integer
>         Dim Kmt As Variant

>         For Idx = 1 to 5
>                 For Kmt = 19.1 to 30.1
>                         cboKmt(Idx).AddItem (Kmt)
>                 Next Kmt
>         Next Idx

> This code doesn't work since i just get the whole number: 19.1 - 20.1 - 21.1 etc.
> I want all the numbers from 19.1 to 30.1 : 19.1 - 19.2 - 19.3 etc.

> If someone can help me with this, It would be appreciated.

> Kris D.



Mon, 25 Dec 2000 03:00:00 GMT  
 Filling a combobox with decimal numbers

Quote:

>I am trying to fill 5 comboboxes with decimal numbers.
>I have set the comboboxes in a control array from index 1 to 5.

>Here's the code i have so far :

>    Dim Idx As Integer
>    Dim Kmt As Variant

>    For Idx = 1 to 5
>            For Kmt = 19.1 to 30.1
>                    cboKmt(Idx).AddItem (Kmt)
>            Next Kmt
>    Next Idx

>This code doesn't work since i just get the whole number: 19.1 - 20.1 - 21.1 etc.
>I want all the numbers from 19.1 to 30.1 : 19.1 - 19.2 - 19.3 etc.

>If someone can help me with this, It would be appreciated.

>Kris D.

Try This ---

        For Idx = 1 to 5
                For Kmt = 19.1 to 30.1 step 0.1
                        cboKmt(Idx).AddItem (Kmt)
                Next Kmt
        Next Idx

Barry
eggers1 AT tsil DOT net



Fri, 29 Dec 2000 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Exporting a 3 decimal number to text file produces trunc 2 decimal text number

2. Filling a Secondary Combobox based on information from a primary combobox

3. Rounding number up to a given number of decimals

4. Getting the number of decimal places from a number

5. extracting a decimal and zero filling a field

6. Loading decimals in Combobox

7. Programatically fill a combobox A2K ??

8. Using the pipe symbol to fill a listbox or combobox

9. ComboBox Custom Fill Functions

10. fill combobox with contents directory

11. Reference ComboBox item to fill ListBox

12. Fill a combobox

 

 
Powered by phpBB® Forum Software