problem with decimal number not displaying

E

Ellen

I'm trying to write some code that will divide a number by two and give a
decimal result. So 33 divided by 2 would give me 16.50, not 16, like I'm
getting.

Do you know if I'm doing this wrong or if this is a Word limitation?

Dim cLA1 As Currency
Dim cLA1Half as Currency

cLA1 = "33.00" (I've tried it with and without the quote marks - it
doesn't seem to make any difference)
cLA1Half = Format((cLA1 \ 2), "$#,##0.00;($#,##0.00)")
MsgBox cLA1Half
 
T

Tony Jollans

The backslash "\" is the Integer Divide operator so 33 \ 2 = 16
The operator for nomal division is a forward slash so 33 / 2 = 16.5

Apart from that you can't assign a string (the result of a format) to a
numeric variable. This should get you going ..

Dim cLA1 As Currency
Dim cLA1Half as Currency

cLA1 = "33.00"
cLA1Half = cLA1 / 2

Msgbox Format(cLA1Half, "$#,##0.00;($#,##0.00)")
 

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