VBI 16.PNG

Private Sub Command1_Click()
Dim n, i, f, x As Integer
n = Val(Text1.Text)
f = 0
For i = 2 To n / 2
    x = n Mod i
    If x = 0 Then
        f = 1
    End If
Next i
If f = 0 Then
    Label2 = n & " Is A Prime Number "
Else
    Label2 = n & " Is Not A Prime Number "
End If
End Sub

VBO 16.PNG

Advertisements