窗体上添加一个按钮,在按钮的单击事件里编写如下代码:
Dim Bit1 As Integer
Dim Bit2 As Integer
Dim Bit3 As Integer
Dim Bit4 As Integer
Dim i As Integer
Dim n As Integer
Me.Cla
n = 0
For i = 1000 To 9999
Bit1 = i Mod 10 '个位数
Bit2 = i \ 10 Mod 10 '十位数
Bit3 = i \ 100 Mod 10 '百位数
Bit4 = i \ 1000 '千位数
If Bit1 + Bit2 + Bit3 + Bit4 = 32 Then
n = n + 1
Print i,
'一行输出5个找到的数字
If n Mod 5 = 0 Then Print
End If
Next i
Print
Print "一共找到:" & n & "个"