Fritz Posted October 22, 2002 Posted October 22, 2002 I have several textboxes to pick up the value of other textboxes and transform the values into percentage. It goes like that: X1.Text = Y1.Text / Z.Text * 100 'Z is 100% X2.Text = Y2.Text / Z.Text * 100 X3.Text = Y3.Text / Z.Text * 100 So far it works, but now I would like to round the values in X1, X2 and X3 to 0 or 2 decimals. And I just don' find any useful example. Can anybody give me a hint? Quote
*Gurus* Derek Stone Posted October 22, 2002 *Gurus* Posted October 22, 2002 Dim d As Decimal d = Math.Round(3.1415, 3) 'Returns 3.142 Quote Posting Guidelines
Fritz Posted October 22, 2002 Author Posted October 22, 2002 I've tried around with that already, but where do I insert my textboxes (X1.Text, X2.Text and X3.Text)? Quote
*Gurus* Derek Stone Posted October 22, 2002 *Gurus* Posted October 22, 2002 X1.Text = Math.Round(Decimal.Parse(Y1.Text) / Decimal.Parse(Z.Text) * 100, 3).ToString() Quote Posting Guidelines
*Gurus* Derek Stone Posted October 22, 2002 *Gurus* Posted October 22, 2002 Would you like anything else on a silver platter? ;) Quote Posting Guidelines
Fritz Posted October 22, 2002 Author Posted October 22, 2002 Just perfect! I was not very far from that, only that I parsed the X-values only , and also didn't put them back to String. Well, great thanks, Mr. Stone Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.