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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Hard drive number 1
Key Pressed 3
BackColor 2
Diplay a label box 2
Running exe 4
Print 1
How do I calculate a check-digit in Excel? 5
help needed in excel 07 0

Back
Top