Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsVB SyntaxEnterprise DevelopmentDatabase AccessControlsCOMWin APICrystal ReportDeploymentGeneralGeneral 2
Related Topics
VB.NET / ASP.NETMS SQL ServerMS AccessOther Database ProductsMore Topics ...

VB Forum / General 2 / October 2004



Tip: Looking for answers? Try searching our database.

Help - round up to 2 decimal places

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Paul Thomas - 27 Oct 2004 20:52 GMT
Hi All

Have a problem with rounding up to two decimal places

Text23.Text = Str$(Val(Text1.Text)) - (Val(Text1.Text)) / (100 +
Val(Text12.Text)) * 100

Text1 = 100
Text12 = 5

Text23 = 4.76 (should look like this) But...

Curently Text23 shows 4.76190476190476

Please help

Many thanks

PS: Tried Format(Math.Round text23.text),2 - no luck  - I know there is a
way involving ####.## but dont know how.
Rogue Rabbit - 27 Oct 2004 21:03 GMT
format(4.76190476190476,"#.00") will give you "4.76"

so

Text23.Text = format((Val(Text1.Text)) - (Val(Text1.Text)) / (100 +
Val(Text12.Text)) * 100, "#.00)

should do it for you
rr

> Hi All
>
[quoted text clipped - 16 lines]
> PS: Tried Format(Math.Round text23.text),2 - no luck  - I know there is a
> way involving ####.## but dont know how.
Rogue Rabbit - 27 Oct 2004 21:09 GMT
oops missed a bit

Text23.Text = format((Val(Text1.Text)) - (Val(Text1.Text)) / (100 +
Val(Text12.Text)) * 100, "#.00")

that's better

rr

> format(4.76190476190476,"#.00") will give you "4.76"
>
[quoted text clipped - 26 lines]
>> PS: Tried Format(Math.Round text23.text),2 - no luck  - I know there
>> is a way involving ####.## but dont know how.
Randy Birch - 28 Oct 2004 04:44 GMT
http://vbnet.mvps.org/code/helpers/numfuncs.htm

Signature

Randy Birch
MS MVP Visual Basic
http://vbnet.mvps.org/

: Hi All
:
[quoted text clipped - 16 lines]
: PS: Tried Format(Math.Round text23.text),2 - no luck  - I know there is a
: way involving ####.## but dont know how.
mickey - 30 Oct 2004 21:01 GMT
>Hi All
>
[quoted text clipped - 16 lines]
>PS: Tried Format(Math.Round text23.text),2 - no luck  - I know there is a
>way involving ####.## but dont know how.

Lookup the 'round' function

Groetjenz,

Mickey
Signature

#### gewoan skrieve su ast ut seist ####

Rick Rothstein - 30 Oct 2004 22:25 GMT
> >Have a problem with rounding up to two decimal places
> >
[quoted text clipped - 16 lines]
> >
> Lookup the 'round' function

Providing you want the Banker's Rounding that it uses for its rounding
operation.

Rick - MVP
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.