English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
所有分類

為什麼輸入16以下都是0種??
這個題目是輸入一個金額 假如大於50元以上 50元 10元 5元 1元 都要用 至少要有一個
假如小於16元 10元就不能用 因為至少都要有一個 依此類推 請大大幫解
Private Sub Form_Activate()
Dim a As Integer, m As Integer, n50 As Integer, n10 As Integer, n5 As Integer, n1 As Integer
a = 0
m = InputBox(\"請輸入金額\")
If m >= 66 Then
For n1 = 1 To (m / 1)
For n5 = 1 To (m / 5)
For n10 = 1 To (m / 10)
For n50 = 1 To (m / 50)
If n50 * 50 + n10 * 10 + n5 * 5 + n1 * 1 = m Then
a = a + 1
Print a, n50, n10, n5, n1
End If
Next n50
Next n10
Next n5
Next n1

ElseIf 16 <= m & m < 66 Then
For n1 = 1 To (m / 1)
For n5 = 1 To (m / 5)
For n10 = 1 To (m / 10)
If n10 * 10 + n5 * 5 + n1 * 1 = m Then
a = a + 1
Print a, n10, n5, n1
End If
Next n10
Next n5
Next n1

ElseIf 6 <= m & m < 16 Then
For n1 = 1 To (m / 1)
For n5 = 1 To (m / 5)
If n5 * 5 + n1 * 1 = m Then
a = a + 1
Print a, n5, n1
End If
Next n5
Next n1

ElseIf m < 6 Then
For n1 = 1 To (m / 1)
If n1 * 1 = m Then
a = a + 1
Print a, n5, n1
End If
Next n1
End If
Print \"兌換的方法有\"; a; \"種\"

End Sub

2006-02-28 12:27:59 · 1 個解答 · 發問者 Anonymous in 電腦與網際網路 程式設計

1 個解答

出在語法的問題
ElseIf 16 <= m & m < 66 Then改成 ElseIf 16 <= m And m < 66 Then
ElseIf 6 <= m & m < 16 Then改成 ElseIf 6 <= m And m < 16 Then

2006-02-27 22:01:52 · answer #1 · answered by W.J.S. 7 · 0 0

fedest.com, questions and answers