hi,

i have 2 txtboxes n 1 label, a division if performed wid txtbox1 and txtbox2, then the result displayed in a label.

How can i format the label to display it to 2 dp. my current code is as follows:

Public Class Form1

         [INDENT][/INDENT]Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
                  Application.Exit()
         End Sub

         Private Sub btnCalculate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalculate.Click
                  Dim GPE As Decimal = txtGPE.Text.Length
                  Dim CT As Decimal = txtCT.Text
                  If GPE >= 0 And GPE <= 120 And CT >= 1 And CT <= 30 Then
                           lblGPA.Text = GPE / CT
                  Else
                           MessageBox.Show("Please Check Data again")
                  End If
         End Sub
End Class

1- Please when embedding code, use code tags to make yout code readable

Dim result As Decimal
        result = Decimal.Divide(Decimal.Parse(TextBox1.Text), Decimal.Parse(TextBox2.Text))
        result = FormatNumber(result, 2, TriState.False)
        Label1.Text = String.Format("the result = {0} ", result)
Comments
Nice Code And Replies
This question has already been answered. Start a new discussion instead.