Here is a sample program that I wrote using Visual Basic NET to ask the user to give a number and then our program will check and determine if the given number is a prime number or not a prime number. Thank you.
My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com.
My mobile number here in the Philippines is 09173084360.
Sample Program Output
Program Listing
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim a, b As Integer
Dim t As Boolean
a = Val(TextBox1.Text)
t = True
For b = 2 To (a - 1)
If a Mod b = 0 Then
t = False
Exit For
End If
Next b
If t Then
Label2.Text = "The number " & a & " is a PRIME Number."
Else
Label2.Text = "The number " & a & " is NOT a PRIME Number."
End If
End Sub
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
End
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
TextBox1.Text = ""
Label2.Text = ""
TextBox1.Focus()
End Sub
End Class
No comments:
Post a Comment