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

Submitted by: 
Visitors have accessed this post 236 times.

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

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • You may insert videos with [video:URL]
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd> <table> <tr> <td> <th> <img> <h1> <h2> <h3> <iframe> [video]
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <asp>, <c>, <cpp>, <csharp>, <css>, <html4strict>, <java>, <javascript>, <mysql>, <php>, <python>, <sql>, <vb>, <vbnet>. The supported tag styles are: <foo>, [foo].
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.
CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.