Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Rounding of decimals in VBA

315 views
Skip to first unread message

Paul

unread,
Jan 2, 2003, 4:44:52 PM1/2/03
to
Hello everybody,

I have a problem of wich I first thought is was simple to solve, but i
just can't figure it out.

I have an Autocad VBA program (acad 2002) with a userform with a textbox in
it.
Next to the textboxt I have a button wich measures a distance in Autocad
with getpoint and
puts the meassured value in the text box (as double). My problem is that it
writes
a lot of decimals in the textbox and I would like to round off the measured
value to
2 decimals. Can anyone please help me with this?

Thanks,
Paul.


TomD

unread,
Jan 3, 2003, 8:24:50 AM1/3/03
to
I think the VBA format function can do it, although the Utility.RealToString
(I think that's it....check the Utility methods) will likely be easier
within Acad.

"Paul" <p...@home.nl> wrote in message
news:av2bsk$m8r$1...@news1.tilbu1.nb.home.nl...

Tim Arheit

unread,
Jan 3, 2003, 12:30:09 PM1/3/03
to

' Round to two decimal places...
TextBox1.Text = Format(1.2345466, "0.00")

-Tim

AlfaSierra

unread,
Jan 4, 2003, 7:58:26 PM1/4/03
to
Maybee it has something to do with the variable LUPREC in Autocad that
defines number of decimal units

"Paul" <p...@home.nl> wrote in message
news:av2bsk$m8r$1...@news1.tilbu1.nb.home.nl...

Paul

unread,
Jan 5, 2003, 10:03:26 AM1/5/03
to
Thanks a lot!
Format works fine.

Paul

"Tim Arheit" <tar...@wcoil.com> wrote in message
news:av4hb1$bil$0...@65.17.150.149...

jr Heathcote

unread,
Jan 5, 2003, 5:20:57 PM1/5/03
to
Since you are writing string data you should probably use the Format$()
instead of the variant version Format().

JR


"Tim Arheit" <tar...@wcoil.com> wrote in message
news:av4hb1$bil$0...@65.17.150.149...

0 new messages