Sunday, April 9, 2017

Odd and Even Number in Visual Basic NET

A very simple program that I wrote using Visual Basic NET to ask the user to give a number and then the program will check if the given number is an EVEN or ODD number. The code is very easy to understand and use. 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 Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
        End
    End Sub

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim val_me As Integer
        Dim isEven As Boolean
        val_me = Val(TextBox1.Text)
        If val_me Mod 2 = 0 Then
            isEven = True
            Label2.Text = "The number " & " " & val_me & " is an EVEN number" & "."
        Else
            Label2.Text = "The number " & " " & val_me & " " & "is an ODD number" & "."
        End If
    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