Function IsWs(m As Integer)
Dim i%, s%, d$
For i = 1 To m / 2
If m Mod i = 0 Then
s = s + i
d = d & "+" & i
End If
Next i
If s = m Then IsWs = Right(d, Len(d) - 1)
End Function
Private Sub Form_Click()
Dim i%, c
Print "2-10000以内的完全数为:"
For i = 2 To 10000
c = IsWs(i)
If c <> "" Then
Print i & "=" & c
End If
Next i
MsgBox "计算完毕!"
End Sub