decimal numbers in a listbox

S

Southern at Heart

I have a listbox with a row source type a 'value list'. the list is:
..25
..5
1
5

My problem is this line:
intNumber = me.listbox.value

....if 1 or 5 was chosen, it works fine, if not, then intNumber is zero. I
need to do some calculations with this number...
How do I fix this problem?
thanks.
 
B

BeWyched

Looks like intNumber is declared as an integer. To pick up the 0.25 or 0.5 it
needs to be a single-precision floating-point declaration, so decalre as
follows:

Dim intNumber as Single
 
J

John W. Vinson

I have a listbox with a row source type a 'value list'. the list is:
.25
.5
1
5

My problem is this line:
intNumber = me.listbox.value

...if 1 or 5 was chosen, it works fine, if not, then intNumber is zero. I
need to do some calculations with this number...
How do I fix this problem?
thanks.

An integer is, by definition, a whole number. If you don't want intNumber to
be a whole number, dim it as a more appropriate datatype - Single, Double,
Decimal or Currency.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top