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.
Open Microsoft Visual Studio 2015 and create a new windows form application.
Do the form just like shown below.
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.
- 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
Write this code for the clear button.
- Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
- End Sub
Write this code for the exit button.
- Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
- 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.