Search This Blog

Showing posts with label perfect number checker. Write a program to check the number is perfect or not. Show all posts
Showing posts with label perfect number checker. Write a program to check the number is perfect or not. Show all posts

Saturday, 14 April 2018

Write a program to check the number is perfect or not | Perfect number checker in VB 6.0

Write a program to check the number is perfect or not | Perfect number checker in VB 6.0.

Design



Private Sub Command1_Click()
Dim n As Integer, i As Integer, s As Integer
n = Val(Text1.Text)

For i = 1 To n / 2
If n Mod i = 0 Then
s = s + i
End If
Next i
If s = n Then
MsgBox "Perfect"
Else
MsgBox "Not Perfect"
End If
End Sub

Thank You