integer division

JuggaloBrotha

VB.NET Forum Moderator
Staff member
Joined
Jun 3, 2004
Messages
4,530
Location
Lansing, MI; USA
Programming Experience
10+
what's the best way to check an integer and see if it's evenly divisible by 5 as in there's no remainder?

is it If (Integer Mod 5) = 0 Then....?
 
Last edited:
I don't see why you ask if you already know the answer :p
Of course it is the way to find whether it is divisible by 5 i.e.
VB.NET:
For[/color][/size][size=2] i = 1 [/size][size=2][color=#0000ff]To[/color][/size][size=2] 100
 
[/size][size=2][color=#0000ff]If[/color][/size][size=2] i [/size][size=2][color=#0000ff]Mod[/color][/size][size=2] 5 = 0 [/size][size=2][color=#0000ff]Then
 
[/color][/size][size=2]TextBox1.Text &= i & ", " [color=darkgreen]'will return:5, 10, 15, 20 and so on ....[/color]
 
[/size][size=2][color=#0000ff]End [/color][/size][size=2][color=#0000ff]If
 
[/color][/size][size=2][color=#0000ff]Next




Regards ;)
 
lol yea, actually i posted the question then 2 hours later i kinda guessed it and i thought i'd edit the post just to make sure

thanx for confirming though :)
 
Back
Top