In this article I would like to share with you a sample program that will ask the user to give a series of numbers and then our program will compute the total sum of digits based on the given number by our user using Visual Basic NET. The code is very short and easy to understand.
My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com.
My mobile number here in the Philippines is 09173084360.
Sample Program Output
Program Listing
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim n, sum, r As Integer
n = Val(TextBox1.Text)
sum = 0
While n <> 0
r = n Mod 10
sum += r
n \= 10
End While
Label2.Text = " The Sum of Digits is " + sum.ToString() + "."
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
End
End Sub
End Class
No comments:
Post a Comment