Hi there first of all thank you very much for visiting my website. I am very happy that the visitors of my website is growing everyday even though I did not earn any money from this endeavor but I would like to share my passion about programming.
In this article I would like to share with you a sample program that I wrote in Visual Basic NET and ASP.NET I called this program odd and even number checker in ASP.NET. Programming in ASP.NET is very new to me because I am a PHP developer for a long period of time. I find it very easy to create a web application using my existing knowledge in Visual Basic.
What does the program will do is to ask the user to give a number and then our program will determine and check if the given number is odd or even number. The code is very simple and easy to understand. I am using Microsoft Visual Studio 2008 as my working environment in writing this code. I hope you will like my work.
My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com.
My mobile number here in the Philippines is 09173084360.
My telephone number at home here in Bacolod City, Negros Occidental is (034) 4335675.
Sample Program Output
Program Listing
Default.aspx
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Odd and Even Number Checker in ASP.NET</title>
</head>
<style type="text/css">
body
{
font-family:Arial;
background-color:lightgreen;
font-size:larger;
font-weight:bolder;
}
.blue_me
{
font-family:Arial;
font-size:medium;
font-weight:bolder;
color:blue;
}
</style>
<body>
<form id="form1" runat="server">
<div>
<br />
Odd and Even Number Checker in ASP.NET</div>
<p class="blue_me">
Created By Mr. Jake R. Pomperada, MAED-IT</p>
Enter a number
<asp:TextBox ID="TextBox1" runat="server" Font-Names="Arial" Font-Size="Medium"></asp:TextBox>
<br />
<br />
<asp:Label ID="Label1" runat="server"></asp:Label>
<p>
<asp:Button ID="Button1" runat="server" Font-Bold="True" Font-Size="Medium"
Text="Check"
ToolTip="Click here to determine if the given number is an odd or even." />
<asp:Button ID="Button2" runat="server" Font-Bold="True" Font-Size="Medium"
Text="Clear"
ToolTip="Click here to clear the textbox and label." />
</p>
<p>
</p>
</form>
</body>
</html>
Default.aspx.vb
Partial Class _Default
Inherits System.Web.UI.Page
Function IsOdd(ByVal iNum As Integer) As Boolean
IsOdd = ((iNum \ 2) * 2 <> iNum)
End Function
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
If TextBox1.Text = "" Then
MsgBox("Cannot be empty")
TextBox1.Text = ""
Label1.Text = ""
TextBox1.Focus()
Exit Sub
End If
If IsOdd(Val(TextBox1.Text)) = True Then
Label1.Text = "The given number " & TextBox1.Text & " is an ODD number."
Else
Label1.Text = "The given number " & TextBox1.Text & " is an EVEN number."
End If
End Sub
Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click
Label1.Text = ""
TextBox1.Text = ""
TextBox1.Focus()
End Sub
End Class