Whole Numbers

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hey guys

Quick question: how do i find out if the remainder of 4 divided by 2 is a whole number ?

NEED CODE PLEAS

THANX IN ADVANCE
 
You can use Mod, because any whole number Mod 1 = 0. For example:

Debug.WriteLine( (4 / 2) Mod 1 = 0) ' writes True
Debug.WriteLine( (4 / 3) Mod 1 = 0) ' writes False
 
I assume you mean "how do I tell if the quotient (result) of 4 divided by 2
is a while number?". See code below; the second example is preferable.
There are several more ways to do this.

Prester John



Dim n1 As Decimal = 3

Dim n2 As Decimal = 2

If Int(n1 / n2) = n1 / n2 Then

MsgBox("Whole number")

Else

MsgBox("Not a whole number")

End If

----or------

Dim n1 As Decimal = 4

Dim n2 As Decimal = 2

If Decimal.Remainder(n1, n2) = 0 Then

MsgBox("Whole number")

Else

MsgBox("Not a whole number")

End If
 
Back
Top