程序及运行图如下:
Dim n100, n50, n10, n5, n1
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
x = Val(Text1.Text)
n100 = x \ 100
x = x - n100 * 100
n50 = x \ 50
x = x - n50 * 50
n10 = x \ 10
x = x - n10 * 10
n5 = x \ 5
x = x - n5 * 5
n1 = x \ 1
Call xianshi
End If
End Sub
Private Sub xianshi()
Print "100元: "; n100; " 张"
Print "50元: "; n50; " 张"
Print "10元: "; n10; " 张"
Print "5元: "; n5; " 张"
Print "1元: "; n1; " 张"
End Sub