hello i am trying to make a program for prime numbers but facing some problem can any one can help me in making this program

you didn't say what your problem. try this to check whether given number is a Prime Number

``````Option Explicit

Public Function IsPrime(ByVal n As Long) As Boolean
Dim I As Long
IsPrime = False
If n <> 2 And (n And 1) = 0 Then Exit Function 'test if div 2
If n <> 3 And n Mod 3 = 0 Then Exit Function 'test if div 3
For I = 6 To Sqr(n) Step 6
If n Mod (I - 1) = 0 Then Exit Function
If n Mod (I + 1) = 0 Then Exit Function
Next I
IsPrime = True
End Function``````

thanks for your response dear but its showing compile error "invalid inside procedure"
sorry for incomplete description actually i need a program to print prime numbers from 1 to 100
i am working in vb6. and putting this coding in command button on click event, please check and reply.

actually i have made a program which is creating all of the non-prime numbers from 1 to 100 but i am unable to compare it... and generate prime numbers...

this is the program

``````Private Sub Command1_Click()
Dim o As Integer
Dim z As Integer
Dim y As Integer
Dim x As Integer
Dim W As Integer
Dim a(114) As Integer

o = 0
For z = 2 To 50
o = o + 1
a(o) = z * 2
Next z

For y = 2 To 33
o = o + 1
a(o) = y * 3
Next y

For x = 2 To 20
o = o + 1
a(o) = x * 5
Next x

For W = 2 To 14
o = o + 1
a(o) = W * 7
Next W

End Sub``````

Start by describing how you can tell if a number is prime.

You can try this. in your code you use huge code.

Thanks abu tahir for your help