A very simple program that I wrote using Visual Basic NET to ask the user to give a number and then the program will check if the given number is a PERFECT number or NOT a PERFECT number. The code is very easy to understand and use. Thank you.
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(sender As Object, e As EventArgs) Handles Button1.Click
Dim n, sum, p, r As Integer
n = Val(TextBox1.Text)
p = 1
sum = 0
While p <= n \ 2
r = n Mod p
If r = 0 Then
sum += p
End If
p += 1
End While
If sum = n Then
Label2.Text = "The number " & n & " is a PERFECT Number."
Else
Label2.Text = "The number " & n & " is NOT a PERFECT Number."
End If
End Sub
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
End
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
TextBox1.Text = ""
Label2.Text = ""
TextBox1.Focus()
End Sub
End Class
No comments:
Post a Comment