11,923,517 members (64,994 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 310 Sergey Alexandrovich Kryukov 280 Richard MacCutchan 205 Richard Deeming 200 CHill60 130
 OriginalGriff 7,266 KrunalRohit 4,560 Sergey Alexandrovich Kryukov 3,476 George Jonsson 2,905 Suvendu Shekhar Giri 2,246

Web04 | 2.8.151125.3 | Last Updated 8 Jul 2010