Private Sub cmdPrime_Click()

Dim p, n, i As Integer

p = 1

Print “Prime Numbers are : ”

For n = 1 To 100

For i = 2 To n – 1

If n Mod i = 0 Then

p = 0

Exit For

Else

p = 1

End If

Next

If p = 1 Then

Print n

End If

Next

End Sub

Private Sub cmdPrime_Click()

Dim p, n, i As Integer

p = 1

Print “Prime Numbers are : ”

For n = 1 To 100

For i = 2 To n – 1

If n Mod i = 0 Then

p = 0

Exit For

Else

p = 1

End If

Next

If p = 1 Then

Print n

End If

Next

End Sub

%d bloggers like this:

Pls give a simpler code for this program

its already simple