Link to home
Create AccountLog in
Avatar of Jason
JasonFlag for Australia

asked on

Combobox formular for form load

I am after formula help

I have a combobox and i need it to list currency in increments of 10 cents

I have this

            Dim h
            Dim h1 As String
            For h = 1 To 50
                h1 = h + 0.1
                cboMin.Items.Add("$" & h1)
                cboMax.Items.Add("$" & h1)
            Next h

But the results of this is
$1.1
$2.1
$3.1
etc
What I need is
$1.10
$1.20
$1.30
etc

The formula need to start from $1.00 up to $5.00
ASKER CERTIFIED SOLUTION
Avatar of Carlos Villegas
Carlos Villegas
Flag of United States of America image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Also you can try:
Dim h as Integer
Dim h1 As Decimal = 0
For h = 1 To 50
    h1 += 0.1
    cboMin.Items.Add(h1.ToString("C"))
    cboMax.Items.Add(h1.ToString("C"))
Next h

Open in new window

Avatar of Jason

ASKER

Thks
You're welcome, but I think that you really need is this:
Dim h1 As Decimal = 1
Dim txt As String
Do While h1 <= 5
    cboMin.Items.Add("$" + h1.ToString("N"))
    cboMax.Items.Add("$" + h1.ToString("N"))    
    h1 += 0.1
Loop

Open in new window

Ignore line #2
Avatar of Jason

ASKER

yv989c:

Thanks I just added an if statement in to handle the > $1
So all good thks for your help