Divisors
This code show how to find the divisors of the given number.
Private Sub Divisors()
Dim intNum, intDiv As Integer
Dim strDiv As String = ""
'Consider variable intNum as number
'whose divisors are to be searched.
intNum = 100
'Every number is divisible by 1.
'So start dividing from 1.
intDiv = 1
While (intDiv < intNum / 2)
'If the remainder is 0 then
'the current value of intDiv
'is the divisor of the number intNum.
If intNum Mod intDiv = 0 Then
'Save all the divisors in the variable strDiv.
If strDiv.Length = 0 Then
strDiv = intDiv
Else
strDiv = strDiv & "," & intDiv
End If
End If
intDiv = intDiv + 1
End While
MessageBox.Show(strDiv)
End Sub