Home Uncategorized Prime Or Not Prime vb.net Program.

Prime Or Not Prime vb.net Program.

2 min read
0
0
23

Prime Or Not Prime .


Public Class Form1

Dim n As Integer

Dim a As Integer

Dim i As Integer

Dim fact As Integer = 1

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

Even()

End Sub

Sub Even()

n = TextBox1.Text

If n Mod 2 = 0 Then

MsgBox("number is even" & n)

Else

MsgBox("number is odd" & n)

End If

End Sub

Sub factorial()

n = TextBox1.Text

For i = 1 To n

fact = fact * i

Next

MsgBox("factorial of no:" & fact)

End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

factorial()

End Sub

Public Function prime() As Integer

Dim f As Integer = 0

n = TextBox1.Text

For i = 1 To n - 1

If n Mod i = 0 Then

f = 1

Ed If

Next

If f = 0 Then

MsgBox("prime number")

Else

MsgBox("not prime number")

End If

End Function

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click

prime()

End Sub

 

Load More Related Articles
Load More By coder coder
  • Moveiclip Play Stop in Flash

Load More In Uncategorized

Leave a Reply

Your email address will not be published. Required fields are marked *

Check Also

Fact & Even & Prime Vb.net Program.

Fact & Even & Prime Vb.net Program. Public Class Form1 Dim n As Integer Dim a As I…