Private Sub IsPrime(ByVal n As Integer, ByRef b As Boolean) b = True For i = 2 To Sqr(n) If n Mod i = 0 Then b = False Exit For End If Next iEnd Sub