I am using Visual Basic Express. Here is my code but my number is always a whole number when I divide I want it to be two decimal places. For example 367/12 should equal 30.42 not just 30.

I do not understand what I am doing wrong?

Private Sub btnIntegerDivide_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles btnIntegerDivide.Click

' Perform integer division
Dim intResult As Integer
lblOperation.Text = "\"
intResult = CInt(txtNumber1.Text) \ CInt(txtNumber2.Text)
lblResult.Text = CStr(intResult)

Recommended Answers

All 2 Replies

I am using Visual Basic Express. Here is my code but my number is always a whole number when I divide I want it to be two decimal places. For example 367/12 should equal 30.42 not just 30.

I do not understand what I am doing wrong?

Private Sub btnIntegerDivide_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles btnIntegerDivide.Click

' Perform integer division
Dim intResult As Integer
lblOperation.Text = "\"
intResult = CInt(txtNumber1.Text) \ CInt(txtNumber2.Text)
lblResult.Text = CStr(intResult)

Textbox1.Text = FormatNumber(TextBox1.Text, 2)
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.