用vb计算100到999中有多少个数其各位数之和等于5

问题描述:

用vb计算100到999中有多少个数其各位数之和等于5

Private Sub Form_Click()
For i = 100 To 999
a = i \ 100
b = (i - a * 100) \ 10
c = i Mod 10
If a + b + c = 5 Then Print a & b & c
Next i
End Sub

还想简单就这么写:
Private Sub Form_Click()
For i = 100 To 999
If Val(Left(i, 1)) + Val(Mid(i, 2, 1)) + Val(Right(i, 1)) = 5 Then Print i
Next i
End Sub