Calculate the Sum of Even Digits of the Given Numbers in VB.Net
Submitted by janobe on Thursday, October 25, 2018 - 19:23.
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.
For any questions about this article. You can contact me @
Email – [email protected]
Mobile No. – 09305235027 – TNT
Or feel free to comment below.
Creating Application
Step 1
Open Microsoft Visual Studio 2015 and create a new windows form application.
Step 2
Do the form just like shown below.
Step 3
Double click the calculate button to fire theclick event handler
of it and do the following codes for calculating the sum of even digits of a given number.
- Dim accptNumber, R, Ans As Integer
- accptNumber = Val(TextBox1.Text)
- While accptNumber > 0
- R = accptNumber Mod 10
- accptNumber = accptNumber \ 10
- If R Mod 2 = 0 Then
- Ans = Ans + R
- End If
- TextBox2.Text = Ans
- End While
Step 4
Write this code for the clear button.- Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
- TextBox1.Clear()
- TextBox2.Clear()
- TextBox1.Focus()
- End Sub
Step 5
Write this code for the exit button.- Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
- Me.Close()
- End Sub
Add new comment
- 746 views