
-----------------------------------
Silent Avenger
Wed Nov 29, 2006 9:33 pm

How do you &quot;cut off&quot; a decimal?
-----------------------------------
Okay I making a program where I input and output prices and I would like to know how to make the decimal go to only 2 places. I've already tried using the variable as a currency type but it still doesn't work.

-----------------------------------
[Gandalf]
Thu Nov 30, 2006 12:40 am


-----------------------------------
You'll want to look into either rounding, or truncating.

-----------------------------------
wtd
Thu Nov 30, 2006 1:58 am


-----------------------------------
Understand why many languages call functions that do just this kind of thing "ceil" and "floor".

-----------------------------------
Monstrosity_
Thu Nov 30, 2006 3:43 pm

Re: How do you &quot;cut off&quot; a decimal?
-----------------------------------
Okay I making a program where I input and output prices and I would like to know how to make the decimal go to only 2 places. I've already tried using the variable as a currency type but it still doesn't work.
The Currency just provides a different method of storage for your numbers, since you wouldn't use floating-point numbers things such as currency.
As for the decimal places, look into the FormatCurrency() function.

-----------------------------------
cool dude
Thu Nov 30, 2006 5:11 pm


-----------------------------------
you don't need currency. to round of to 2 decimal places use the format command and inside the brackets the name of the variable you want to round to 2 decimal places and "0.00"  

Example


    quotient = 20 / 26
    Text1.Text = Format(quotient, "0.00")


if you want to round to 3 decimal places you would add an extra 0. and so on.

-----------------------------------
Silent Avenger
Thu Nov 30, 2006 5:31 pm


-----------------------------------
Wow thanks for all the help everyone!

-----------------------------------
wtd
Fri Dec 01, 2006 12:32 am

Re: How do you &quot;cut off&quot; a decimal?
-----------------------------------
The Currency just provides a different method of storage for your numbers, since you wouldn't use floating-point numbers things such as currency.

Indeed.  Never ever use floating point numbers for currency.

If you feel tempted to do so, just watch the movie Office Space.

-----------------------------------
RGB255
Sat Dec 02, 2006 10:40 pm


-----------------------------------
This could come in very hany in my final project. Btw what are floating point numbers?

-----------------------------------
[Gandalf]
Sun Dec 03, 2006 12:33 am


-----------------------------------
Floating point numbers, as basically as you can get, are numbers with decimals, for example:
1.56
0.065
16342.6

You could have found this out from a simple Google/Wikipedia search.
