VB:用调用函数的方法找出所有三位数的水仙花数.

问题描述:

VB:用调用函数的方法找出所有三位数的水仙花数.
这是我写的代码:
Private Sub Command1_Click()
Dim a(101,999) As Integer
For a = 101 To 999 Step 1
If isnum = True Then Print a;
Next
End If
End Sub
Private Function isnum(n As Integer) As Boolean
a As Integer,b As Integer,c As Integer
a = n \ 100
b = n \ 10 Mod 10
c = n Mod 10
If n = a ^ 3 + b ^ 3 + c ^ 3 Then
isnum = True
Else
isnum = False
End If
End Function
运行时说我类型不匹配.
哪个类型啊?
帮我解决掉的加分.

Private Sub Command1_Click()
Dim a As Integer
For a = 101 To 999 Step 1
If isnum(a) = True Then Print a;
Next
End Sub
Private Function isnum(n As Integer) As Boolean
Dim a As Integer, b As Integer, c As Integer
a = n \ 100
b = (n - a * 100) \ 10
c = n - a * 100 - b * 10
If n = a ^ 3 + b ^ 3 + c ^ 3 Then
isnum = True
Else
isnum = False
End If
End Function