Home   :  Code   :  Forums   :  Submit   :  Mailing List   :  About   :  Contact
A1VBCode Forums
 Home Search Members Calendar Who's On
Welcome Guest ( Login | Register )
 Recent PostsRecent Posts Popular TopicsPopular Topics

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

 rounding to two decimal places Rate Topic Display Mode Topic Options
Author
 Message
 Scuba_SteveScuba_Steve
 Posted 3/7/2006 9:08:18 PM
 Junior MemberGroup: Forum MembersLast Login: 3/20/2006 11:45:08 PMPosts: 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.22Thanks
Post #17458
 DestroyerDestroyer
 Posted 3/7/2006 10:55:03 PM
 Supreme BeingGroup: Forum MembersLast Login: 11/30/2015 6:54:40 PMPosts: 243, Visits: 184
 Use the Round function. It takes two parameters. The number and the number of decimal positions.Round(Number,2)Destroyer
Post #17459
 Scuba_SteveScuba_Steve
 Posted 3/9/2006 11:28:04 AM
 Junior MemberGroup: Forum MembersLast Login: 3/20/2006 11:45:08 PMPosts: 24, Visits: 44
 How would I use the round function for this code?Private Sub cmdCalculate_Click()intNumber = CInt(txtDepth.Text)Select Case cboGas.ListIndexCase 0lblATA = ((intNumber + 33) / 33) * 0.32Case 1lblATA = ((intNumber + 33) / 33) * 0.36End SelectEnd SubThanks
Post #17505
 MobiusMobius
 Posted 3/9/2006 1:07:35 PM
 Forum GodGroup: Forum MembersLast Login: 9/7/2010 12:29:54 PMPosts: 632, Visits: 1,019
 Private Sub cmdCalculate_Click()intNumber = CInt(txtDepth.Text)Select Case cboGas.ListIndexCase 0lblATA = round ((((intNumber + 33) / 33) * 0.32), 2)Case 1lblATA = round((((intNumber + 33) / 33) * 0.36), 2)End SelectEnd Sub -Mobius
Post #17508
 Scuba_SteveScuba_Steve
 Posted 3/10/2006 7:54:59 PM
 Junior MemberGroup: Forum MembersLast Login: 3/20/2006 11:45:08 PMPosts: 24, Visits: 44
 Thanks Guys, that helped out Alot!!
Post #17540
 « Prev Topic | Next Topic »