0

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)

3
Contributors
2
Replies
4
Views
6 Years
Discussion Span
Last Post by bLuEmEzzy
0

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)
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.