Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to convert answer into two decimal point

Tags:

vb.net

This is my code and I want the output which is txtA.Text and txtB.Text to be in two decimal places.

Public Class Form1
    Private Sub btncalc_Click(ByVal sender As System.Object,
                              ByVal e As System.EventArgs) Handles btncalc.Click
      txtA.Text = Val(txtD.Text) / Val(txtC.Text) * Val(txtF.Text) / Val(txtE.Text)
      txtB.Text = Val(txtA.Text) * 1000 / Val(txtG.Text)
    End Sub
End Class
like image 816
Husna5207 Avatar asked May 16 '13 07:05

Husna5207


People also ask

How do you give an answer to 2 decimal places?

Rounding to a certain number of decimal places4.737 rounded to 2 decimal places would be 4.74 (because it would be closer to 4.74). 4.735 is halfway between 4.73 and 4.74, so it is rounded up: 4.735 rounded to 2 decimal places is 4.74.

What is the number 2.738 correct to 2 decimal places?

74, which is 2 decimal places.

How do I change to 2 decimal places in Word?

Click the Table Tools' Layout tab, select Data and then click Formula. Click the Number Format menu and select 0.00 for two decimals.


Video Answer


1 Answers

For formatting options, see this

Dim v1 as Double = Val(txtD.Text) / Val(txtC.Text) *
                   Val(txtF.Text) / Val(txtE.Text)
txtA.text = v1.ToString("N2");
like image 110
fnostro Avatar answered Oct 21 '22 18:10

fnostro