Visual Basic Code , VB.NET Code, VB Code
  Home   :  Code   :  Forums   :  Submit   :  Mailing List   :  About   :  Contact
A1VBCode Forums
Home      Members   Calendar   Who's On
Welcome Guest ( Login | Register )
      

Home » Classic Visual Basic (VB 6 or earlier) » General Visual Basic » rounding to two decimal places


rounding to two decimal placesExpand / Collapse
Author
Message
Posted 3/7/2006 9:08:18 PM
Junior Member

Junior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior Member

Group: Forum Members
Last Login: 3/20/2006 11:45:08 PM
Posts: 24, Visits: 44
How would I go about rounding to two decimal places.

I have:

((76+33)/33)* .37 the answer comes out to 1.222121212 I want to have this number end up in a label but with just two decimal places. 1.22

Thanks

Post #17458
Posted 3/7/2006 10:55:03 PM
Supreme Being

Supreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme Being

Group: Forum Members
Last Login: 6/28/2014 8:06:54 PM
Posts: 238, Visits: 179
Use the Round function. It takes two parameters. The number and the number of decimal positions.

Round(Number,2)

Destroyer

Post #17459
Posted 3/9/2006 11:28:04 AM
Junior Member

Junior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior Member

Group: Forum Members
Last Login: 3/20/2006 11:45:08 PM
Posts: 24, Visits: 44
How would I use the round function for this code?

Private Sub cmdCalculate_Click()
intNumber = CInt(txtDepth.Text)

Select Case cboGas.ListIndex
Case 0
lblATA = ((intNumber + 33) / 33) * 0.32
Case 1
lblATA = ((intNumber + 33) / 33) * 0.36
End Select
End Sub

Thanks

Post #17505
Posted 3/9/2006 1:07:35 PM


Forum God

Forum GodForum GodForum GodForum GodForum GodForum GodForum GodForum God

Group: Forum Members
Last Login: 9/7/2010 12:29:54 PM
Posts: 632, Visits: 1,019
Private Sub cmdCalculate_Click()
intNumber = CInt(txtDepth.Text)
Select Case cboGas.ListIndex
Case 0
lblATA = round ((((intNumber + 33) / 33) * 0.32), 2)
Case 1
lblATA = round((((intNumber + 33) / 33) * 0.36), 2)
End Select
End Sub




-Mobius
Post #17508
Posted 3/10/2006 7:54:59 PM
Junior Member

Junior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior Member

Group: Forum Members
Last Login: 3/20/2006 11:45:08 PM
Posts: 24, Visits: 44
Thanks Guys, that helped out Alot!!
Post #17540
« Prev Topic | Next Topic »


Reading This TopicExpand / Collapse
Active Users: 1 (1 guest, 0 members, 0 anonymous members)
No members currently viewing this topic.
Forum Moderators: Admin, Mod, Mark, Keithuk

PermissionsExpand / Collapse

All times are GMT -5:00, Time now is 7:50am