Skip to main content
GameDev.net gamedev.net
🔒 Locked

VB variable division

Started by cowhand214 May 28, 2002 at 11:11 PM 2 replies 350+ views
Original Post
cowhand214
cowhand214
Perhaps I am an idiot. I consider this highly likely as it''s been said before usually by close friends, family, other drivers, complete strangers etc. but I have a rather simple question. I have an integer variable being divided by a number (ie. 3). I then place the result of that operation in the caption property of a label. My problem is I want to cut the number short. For example it doesn''t work to well to have 1.33333333333 in the caption but I do need a couple of decimal places. For some reason (and perhaps I''m not looking hard enough) I can''t seem to find the answer in the help files. Anyway, if someone could drop me a quick line I would appreciate it. Take care, BQ
"Working is the curse of the drinking class." - Oscar Wilde
Cherez
Cherez
Just multiply it by something like 1000 then make it into an int, then divide it by 1000.
(int((4/3)*1000)/1000)
if I remember VB right is what you would all for that.
alexmoura
alexmoura
use the round function:

round(1.3333333,2)

You know, I never wanted to be a programmer...

Alexandre Moura
Zong
Zong
You can use Format()

Dim d As Double
d = 1.3333333
d = Format(d, "0.00")

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.