# How to check if a number is a muliple of

Page 1 of 1

## 3 Replies - 23860 Views - Last Post: 30 April 2010 - 10:21 PMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'https://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=171349&amp;s=52555c6dce7747c7ef6b77ac34b44d2e&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 Ewinz87

Reputation: 0
• Posts: 21
• Joined: 25-May 09

# How to check if a number is a muliple of

Posted 30 April 2010 - 09:36 PM

I can't seem to figure out how to make a function that check if x is a multiple of y. For example, 64 is a multiple of 8.

Here's what I have, it's simple but I'm stuck:

```Function IsMultiple(ByVal Number As Integer, ByVal Multiple As Integer) As Boolean
If Number / Multiple = 0 Then
IsMultiple = True
End If
End Function
```

Line2, if the number is a multiple it would return a number without decimal, but I dunno how to check if it is or not.

Is This A Good Question/Topic? 0

## Replies To: How to check if a number is a muliple of

### #2 PsychoCoder

Reputation: 1659
• Posts: 19,853
• Joined: 26-July 07

## Re: How to check if a number is a muliple of

Posted 30 April 2010 - 09:50 PM

Use the Modulus Operator (Mod)

```Function IsMultiple(ByVal Number As Integer, ByVal Multiple As Integer) As Boolean
If Number Mod Multiple = 0 Then
Return True
End If

Return False
End Function

```

### #3 Ewinz87

Reputation: 0
• Posts: 21
• Joined: 25-May 09

## Re: How to check if a number is a muliple of

Posted 30 April 2010 - 10:05 PM

PsychoCoder, on 30 April 2010 - 08:50 PM, said:

Use the Modulus Operator (Mod)

```Function IsMultiple(ByVal Number As Integer, ByVal Multiple As Integer) As Boolean
If Number Mod Multiple = 0 Then
Return True
End If

Return False
End Function

```

Thank you very much, works perfectly.

### #4 PsychoCoder

Reputation: 1659
• Posts: 19,853
• Joined: 26-July 07

## Re: How to check if a number is a muliple of

Posted 30 April 2010 - 10:21 PM

No problem, glad I could help