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
No comments:
Post a Comment