Calculate the Sum of Even Digits of the Given Numbers in VB.Net

In this tutorial I will teach you how to calculate the sum of even digits of a given number in vb.net. This method has the ability to accept the numbers from user. Then it will calculate the sum of even digits of a given number and display it in the textbox. This is just a simple program to do once you follow the steps below.

Creating Application

Step 1

Open Microsoft Visual Studio 2015 and create a new windows form application. evendigit

Step 2

Do the form just like shown below. evendigots123

Step 3

Double click the calculate button to fire the click event handler of it and do the following codes for calculating the sum of even digits of a given number.
  1. Dim accptNumber, R, Ans As Integer
  2.  
  3. accptNumber = Val(TextBox1.Text)
  4. While accptNumber > 0
  5. R = accptNumber Mod 10
  6. accptNumber = accptNumber \ 10
  7. If R Mod 2 = 0 Then
  8. Ans = Ans + R
  9. End If
  10. TextBox2.Text = Ans
  11. End While

Step 4

Write this code for the clear button.
  1.  
  2. Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
  3. TextBox1.Clear()
  4. TextBox2.Clear()
  5. TextBox1.Focus()
  6. End Sub

Step 5

Write this code for the exit button.
  1.  
  2. Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
  3. Me.Close()
  4. End Sub
For any questions about this article. You can contact me @ Email – [email protected] Mobile No. – 09305235027 – TNT Or feel free to comment below.

Add new comment