12,632,032 members (27,347 online)
Rate this:
See more:
``` ```What is the simpliest way to write code for integer division with a remainder?
Posted 5-Jul-10 7:07am

what have you tried till now please post that too

Rate this:

Solution 1

Checkout the "\" and the "mod" operators.
Rate this:

Solution 2

simple code to do divison:
```    Sub Main()
Dim var1 As Integer = 17
Dim var2 As Integer = 4
Dim resDiv As Integer = var1 / var2 ' resDiv=4
Dim resMod As Integer = var1 Mod var2 ' resMod=1
End Sub
```

and the following full complete example to do division:
```Module Division
Sub Main()
Dim var1 As Integer
Dim var2 As Integer
Console.WriteLine("Enter the first number:")
Console.WriteLine("Enter the second number:")
DivMod(var1, var2)
End Sub
Sub DivMod(ByVal v1 As Integer, ByVal v2 As Integer)
Dim divRes As Integer = v1 / v2
Dim modRes As Integer = v1 Mod v2
Console.WriteLine(String.Format("Division Result:{0} and Remainder Result:{1}", divRes.ToString, modRes.ToString))
End Sub
End Module
```
v2

Top Experts
Last 24hrsThis month
 OriginalGriff 260 Richard MacCutchan 118 Peter Leow 85 Admire Mhlaba 75 F. Xaver 65
 OriginalGriff 1,999 ppolymorphe 1,242 Peter Leow 804 John Simmons / outlaw programmer 665 CPallini 571