1. Write a VB program to find the prime numbers between 1 to100 and display it onto the form.


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

2 thoughts on “1. Write a VB program to find the prime numbers between 1 to100 and display it onto the form.

  1. Sh dragon says:

    Pls give a simpler code for this program

Leave a comment