I want to have a list box which lists numbers from 0 to 10 with one decimal place. Is it possible to get this in a list box without typing them all in?
Printable View
I want to have a list box which lists numbers from 0 to 10 with one decimal place. Is it possible to get this in a list box without typing them all in?
for i = 1 to 10
list1.additem format(i,"99.9")
next i
Try this
[email protected]
Co Galway
Ireland
This code will fill the listbox with the values 0.0, 0.1, 0.2, 0.3, ... , 9.8, 9.9, 10.0
If this is what your loking for. If you only want integers then the code from john_murphy will work.:)
Code:Dim dblNum As Double
List1.Clear
dblNum = 0
Do While dblNum <= 10
List1.AddItem Format(dblNum, "#0.0")
dblNum = dblNum + 0.1
Loop