Dim a() As Integer \\\\\\窗体级变量,只需添加此处 Private Sub Form_Click() Print "1000以内的的完数" For i = 1 To 1000 If IsWs(i) Then Print i; "=1"; For j = 1 To UBound(a) Print "+"; a(j); Next j Print End If Next i End Sub Function IsWs(m) As Boolean Dim s% s = 0 For i = 1 To m \ 2 If m Mod i = 0 Then ReDim Preserve a(j) a(j) = i j = j + 1 s = s + i End If Next i If m = s Then IsWs = True End Function