PDA

View Full Version : Solved: Include decimals in a number range



av8tordude
01-02-2013, 12:17 AM
How can i change this code to include .5 after every whole number? Currently it displays in the combo box -12, -11, -10...0...10, 11, 12. I like it to include -12, 11.5, 11, 10.5, 10 etc., but keep the max range of -12 to 12. Can someone assist. Thank

Dim GMT(1 To 25), i As Long

For i = -12 To 12
GMT(i + 13) = i
Next
Me.cboGMT.List = GMT

patel
01-02-2013, 12:41 AM
Dim GMT(1 To 50), i As Long

For i = -12 To 12 step 0.5
GMT(i + 13) = i
Next
Me.cboGMT.List = GMT

av8tordude
01-02-2013, 04:37 AM
Sry for the late reply...I made the changes, but the changes locks me out, forcing me to force close the program. Any idea?

p45cal
01-02-2013, 05:37 AM
Sry for the late reply...I made the changes, but the changes locks me out, forcing me to force close the program. Any idea?
try changing patel's Long to Double or Single.
Also you can't have array index as a fraction.
What are you trying to do?
Something like this:?
Dim GMT(1 To 49), i As Double, k as Long
k = 1
For i = -12 To 12 Step 0.5
GMT(k) = i
k = k + 1
Next
Me.cboGMT.List = GMT

av8tordude
01-02-2013, 06:04 AM
P45Cal...Yes...this works. I did what you suggest to patel's code (thank you Patel for you assistance.), but it was skipping numbers.

Thanks