Friday, March 26, 2021

Even and Odd Numbers Generator in VB.NET

 A program that I wrote to generate even and odd numbers using vb.net programming language.

I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me at the following email address for further details.  If you want to advertise on my website kindly contact me also in my email address also. Thank you.

My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.






Program Listing


Public Class Form1


    Private Sub btnClear_Click(sender As Object, e As EventArgs) Handles btnClear.Click

        txtInput.Clear()

        txtOutput.Clear()

        lblCountEven.Text = ""

        lblCountOdd.Text = ""

        lblSumEven.Text = ""

        lblSumOdd.Text = ""

        lblLastEven.Text = ""

        lblLastOdd.Text = ""

    End Sub


    Private Sub btnView_Click(sender As Object, e As EventArgs) Handles btnView.Click

        txtOutput.Clear()

        Dim sumEven, sumOdd, countEven, countOdd, lastEven, lastOdd As Integer

        Dim i = 1

        Dim input = txtInput.Text


        While i <= input

            If i Mod 2 = 0 Then

                txtOutput.Text += i & " = Even" & Environment.NewLine

                sumEven += i

                countEven += 1

            Else

                txtOutput.Text += i & " = Odd" & Environment.NewLine

                sumOdd += i

                countOdd += 1

            End If


            If i = input And i Mod 2 = 0 Then

                lastEven = i

                lastOdd = i - 1

            Else

                lastEven = i - 1

                lastOdd = i

            End If


            i += 1

        End While


        lblCountEven.Text = countEven

        lblCountOdd.Text = countOdd

        lblSumEven.Text = sumEven

        lblSumOdd.Text = sumOdd

        lblLastEven.Text = lastEven

        lblLastOdd.Text = lastOdd

    End Sub

End Class


Download the FREE Source Code Here

No comments:

Post a Comment