PROPERTIES:
CODEING:
Lable1 | |
Text | Number |
Button1 | |
Text | Factorial |
Button2 | |
Text | odd/Even |
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
TextBox1.Text = InputBox("Enter Number...")
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
fact(TextBox1.Text)
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
oddeven(TextBox1.Text)
End Sub
Function fact(ByVal num As String) As Double
Dim f As Double = 1
If IsNumeric(num) Then
For i As Integer = 1 To Val(num)
f *= i
Next i
Return MsgBox("Factorial of " & Val(num) & " is: " & f)
Else
Return MsgBox("Input A Numeric Value In Box")
End If
End Function
Sub oddeven(ByVal num As String)
If IsNumeric(num) Then
If Val(num) Mod 2 = 0 Then
MsgBox(num & " is Even Number")
Else
MsgBox(num & " is Odd Number")
End If
Else
MsgBox("Input A Numeric Value In Box")
End If
End Sub
End Class
DESIGNING:Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
TextBox1.Text = InputBox("Enter Number...")
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
fact(TextBox1.Text)
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
oddeven(TextBox1.Text)
End Sub
Function fact(ByVal num As String) As Double
Dim f As Double = 1
If IsNumeric(num) Then
For i As Integer = 1 To Val(num)
f *= i
Next i
Return MsgBox("Factorial of " & Val(num) & " is: " & f)
Else
Return MsgBox("Input A Numeric Value In Box")
End If
End Function
Sub oddeven(ByVal num As String)
If IsNumeric(num) Then
If Val(num) Mod 2 = 0 Then
MsgBox(num & " is Even Number")
Else
MsgBox(num & " is Odd Number")
End If
Else
MsgBox("Input A Numeric Value In Box")
End If
End Sub
End Class
Comments
Post a Comment