there is a thread on the forums that is for vb6. i tried it and it doesnt work.
How is it possible to round to 2d.p?
i tried this:
Label8.Text = round(span.TotalMinutes * lblrate.Text)
the round word is highligted meaning its wrong
can anyone help?
Printable View
there is a thread on the forums that is for vb6. i tried it and it doesnt work.
How is it possible to round to 2d.p?
i tried this:
Label8.Text = round(span.TotalMinutes * lblrate.Text)
the round word is highligted meaning its wrong
can anyone help?
This for VB.NET !
VB Code:
Math.Round(decimal value)
Try Math.Round
Hi.
Use Math.Round.
Many of the functions found in VB6 is still available, but have been placed under different namespaces.
So all mathematical functions are found under the namespace Math.
Hope that made any sence...:D
Edit. Damn Mike. You made it just before I did...:D
math.round only gives me a whole value. Which means it rounds it up to the nearest whole value.
How is it possible to round it up to 2 decimal places?
its ok i worked it out
Side note.
Although I guess I understand the "rules" of rounding, logically this does not make sense to me:
But that's the design.VB Code:
MsgBox(Math.Round(42.5, 0)) ' Displays "42" MsgBox(Math.Round(43.5, 0)) ' Displays "44"
Also there is math.ceiling which will round to the highest integer
ex. 12.1 would return 13
another cool one is math.floor
ex. 12.98 would return 12
also your msgbox is legacy code for message boxQuote:
Originally posted by Mike Hildner
Side note.
Although I guess I understand the "rules" of rounding, logically this does not make sense to me:
But that's the design.VB Code:
MsgBox(Math.Round(42.5, 0)) ' Displays "42" MsgBox(Math.Round(43.5, 0)) ' Displays "44"
it should be messagebox.show(and in here goes your stuff)
it is a overloaded procedure so its much more versatile then
msgbox.
Isn't that the rule of 'rounding towards even'? That's an IEEE standard.Quote:
Originally posted by Mike Hildner
Side note.
Although I guess I understand the "rules" of rounding, logically this does not make sense to me:
But that's the design.VB Code:
MsgBox(Math.Round(42.5, 0)) ' Displays "42" MsgBox(Math.Round(43.5, 0)) ' Displays "44"
Yes it is the rule. Just thought I'd point it out because it can make for some "gotchas" if you're not aware of it.