Reputation: 59
I'm trying to divide input number and show the result without decimals and without rounding it up, so if I divide 80/50 I want to get 1, not 2 (1.6).
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim box1 As Decimal = TextBox1.Text()
TextBox6.Text = box1 / 50
End Sub
End Class
Upvotes: 1
Views: 1248
Reputation: 2484
You can use the \
operator to do integer division.
Dim result = 80 \ 50 'result is Integer with value 1
Upvotes: 3
Reputation: 2695
You can use Truncate
Method of Decimal
:
Dim result As Decimal = Decimal.Truncate(CDec(80 / 50))
Console.WriteLine("result : " & result.ToString)
Upvotes: 4