vb硬币问题

2025-06-27 16:51:35
推荐回答(4个)
回答1:

Private Sub Command1_Click()
For I = 0 To 3
Label1(I).Caption = ""
Next I
Dim M As Single, q As Integer, d As Integer, n As Integer, p As Integer
M = Val(Text1.Text)
If M = 0 Then
    MsgBox "输入需要找的金额!"
    Exit Sub
End If
q = M \ 25
d = (M - 25 * q) \ 10
n = (M - q * 25 - d * 10) \ 5
p = M - q * 25 - d * 10 - n * 5
Label1(0).Caption = q
Label1(1).Caption = d
Label1(2).Caption = n
Label1(3).Caption = p
End Sub

回答2:

华农的吧

回答3:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim n As Integer
n = Val(TextBox1.Text)
Dim type() As Integer = {25, 10, 5, 1}
Dim count(UBound(type)) As Integer
Dim i As Integer
For i = 0 To UBound(type)
count(i) = n \ type(i)
n = n Mod type(i)
Next
For i = 0 To UBound(type)
TextBox2.Text &= type(i) & ":" & count(i) & "个" & vbNewLine
Next
End Sub

回答4:

我可以帮你写作~业,需要可~以联~~系我