Categories
VB.NET

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 and Complete Source Code Here

Categories
VB.NET

Sum of Even Numbers in Visual Basic NET

Write a program in visual basic net  to display the sum of even numbers from 20 to 40.

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

' Author : Jake R. Pomperada, MAED-IT, MIT
' www.jakerpomperada.com  / www.jakerpomperada.blogspot.com
' jakerpomperada@gmail.com
'
' Write a program in visual basic to display the sum of even numbers from 20 to 40.

Public Class Form1
    Public Function GetEvenNumberSum(min As Integer, max As Integer) As Integer
        Dim sum As Integer = 0
        For i As Integer = min To max
            If i Mod 2 = 0 Then
                sum += i
            End If
        Next
        Return sum
    End Function

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        TextBox3.Text = Str(GetEvenNumberSum(Val(TextBox1.Text), Val(TextBox2.Text)))
    End Sub

    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        TextBox1.Text = ""
        TextBox2.Text = ""
        TextBox3.Text = ""
        TextBox1.Focus()
    End Sub

    Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
        End
    End Sub
End Class