2007-06-10 16:51:41
Kenny
收銀機找回最少的錢幣個數
rem 找回最少的錢幣個數,如以百元鈔付款,應找回最少的錢幣個數50元,10元,1元各為若干
Private Sub Command1_Click()
pay = Val(Text1)
buy = Val(Text2)
If pay < buy Then
MsgBox "付款金額不夠!", vbOKOnly
Text1.SetFocus
Exit Sub
End If
a = (pay - buy) \ 500
a0 = (pay - buy) Mod 500
b = a0 \ 100
b0 = a0 Mod 100
c = b0 \ 50
c0 = b0 Mod 50
d = c0 \ 10
e = c0 Mod 10
Text3(0) = a
Text3(1) = b
Text3(2) = c
Text3(3) = d
Text3(4) = e
Text4 = pay - buy
End Sub