楼上的,你写的好像是C代码的思路,如果用VB的话应该注意取整.
下面是VB的代码
Private Sub Command1_Click()
Dim a As Integer,b(1) As Long,c As String
For a = 1000 To 9999 Step 1
b(0) = Int(a / 100)
b(1) = Int(a Mod 100)
If (b(0) + b(1)) * (b(0) + b(1)) = a Then
c = c & CStr(a) & " "
End If
Next a
If c = "" Then
MsgBox "没有满足要求的数.",vbOKOnly
Else
MsgBox "满足要求的数为:" & c & " .",vbOKOnly
End If
End Su