ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Simple Question (https://www.excelbanter.com/excel-programming/342405-simple-question.html)

turnerje[_8_]

Simple Question
 

I have a macro that is calculating a bill, based on large numbers
(15,654,879 for example) by multiplying that large number by a decimal
(.08608). My problem is my object is not keeping the decimals, which
are crucial. The object is dimensioned as "long".

For example,

iVal = iVal * .8608 (for this case iVal = 388)

iVal returns to the sheet "33", not 33.39904, or any decimals at all.
What can I do?

Thanks in advance

Justin


--
turnerje
------------------------------------------------------------------------
turnerje's Profile: http://www.excelforum.com/member.php...o&userid=25694
View this thread: http://www.excelforum.com/showthread...hreadid=474906


Don Guillett[_4_]

Simple Question
 
I just tested this and got

Sub doformat()
ival = 388
ival = ival * 0.0868
MsgBox ival'33.6784
End Sub

try using format
nval=format(ival,"00.0000")

--
Don Guillett
SalesAid Software

"turnerje" wrote in
message ...

I have a macro that is calculating a bill, based on large numbers
(15,654,879 for example) by multiplying that large number by a decimal
(.08608). My problem is my object is not keeping the decimals, which
are crucial. The object is dimensioned as "long".

For example,

iVal = iVal * .8608 (for this case iVal = 388)

iVal returns to the sheet "33", not 33.39904, or any decimals at all.
What can I do?

Thanks in advance

Justin


--
turnerje
------------------------------------------------------------------------
turnerje's Profile:

http://www.excelforum.com/member.php...o&userid=25694
View this thread: http://www.excelforum.com/showthread...hreadid=474906




Gary Keramidas

Simple Question
 
i learned this today, do you have dim ival as integer? that will give a
result of 334
if you dim ival as double, it will give you the desired result, 333.9904


--


Gary


"turnerje" wrote in
message ...

I have a macro that is calculating a bill, based on large numbers
(15,654,879 for example) by multiplying that large number by a decimal
(.08608). My problem is my object is not keeping the decimals, which
are crucial. The object is dimensioned as "long".

For example,

iVal = iVal * .8608 (for this case iVal = 388)

iVal returns to the sheet "33", not 33.39904, or any decimals at all.
What can I do?

Thanks in advance

Justin


--
turnerje
------------------------------------------------------------------------
turnerje's Profile:
http://www.excelforum.com/member.php...o&userid=25694
View this thread: http://www.excelforum.com/showthread...hreadid=474906





All times are GMT +1. The time now is 11:13 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com