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

假設食品清單中各種食品的品名單價依序為 漢堡 25元,奶茶 10 元,可樂 10元,蛋餅 20元,飯團 25 元 ,在食品清單點選食品時,就顯示自動顯示品名與單價,輸入數量後,再按計算鈕,就計算及顯示金額....這個程式如下

Private Sub Command1_Click()
Label3 = Label2 * Text1.Text

End Sub

Private Sub Command2_Click()
End

End Sub

Private Sub List1_Click()
For i = 0 To List1.ListCount - 1
If List1.Selected(i) Then
Label1 = List1.List(i)
s = 1
Label2 = Choose(s i, 25, 10, 10, 10, 20, 25)

Exit For
End If
Next i
要怎樣修改讓這個程式能夠連續處理多項食品的購買,最後再顯示總金額,要如何修改表單及程式(提示可在表單上增加一個顯示總金額的標籤,及一個結帳的命令鈕,按此鈕,就準備處理下一個客戶的資料

2006-01-01 05:42:39 · 2 個解答 · 發問者 1 in 電腦與網際網路 程式設計

不用陣列的方式寫,寫的出來嗎?

2006-01-01 11:40:08 · update #1

2 個解答

Dim A(4) As Integer

Private Sub Cmd結帳_Click()
Dim I As Integer

For I = 0 To List1.ListCount - 1
List1.Selected(I) = False
A(I) = 0
Next
Label1 = "": Label2 = "": Label3 = ""
End Sub

Private Sub Form_Load()
With List1
.AddItem "漢堡", 0: .ItemData(0) = 25
.AddItem "奶茶", 1: .ItemData(1) = 10
.AddItem "可樂", 2: .ItemData(2) = 10
.AddItem "蛋餅", 3: .ItemData(3) = 20
.AddItem "飯團", 4: .ItemData(4) = 25
End With
Label1.WordWrap = True
End Sub

Private Sub List1_Click()
Dim S As String, I As Integer, T As Integer
With List1
If .Selected(.ListIndex) Then
Jp:
S = InputBox("請輸入" & .Text & "購買數量:")
If S = "" Then
.Selected(.ListIndex) = False
Exit Sub
End If
If IsNumeric(S) = False Then GoTo Jp
A(.ListIndex) = Int(S)
Label3 = .Text & "購買" & Int(S) & "個,合計:" & Int(S) * .ItemData(.ListIndex) & "元"
Else
A(.ListIndex) = 0
End If
Label2 = .Text & "單價" & .ItemData(.ListIndex) & "元"
S = ""
For I = 0 To .ListCount - 1
If .Selected(I) Then
S = S & .List(I) & "購買" & A(I) & "個,合計:" & A(I) * .ItemData(I) & "元" & vbCrLf
T = T + A(I) * .ItemData(I)
End If
Next
If T = 0 Then
Label1 = ""
Else
Label1 = S & "總計: " & T & " 元"
End If

End With
End Sub

2006-01-02 14:04:30 補充:
把陣列改成TextBox(0)~(4)來記錄每個單項購買的數量

2006-01-01 10:31:22 · answer #1 · answered by W.J.S. 7 · 0 0

●九州 娛樂 網站 http://ts777.cc
●●●運彩遊戲、真人遊戲、電子遊戲、對戰遊戲、對戰遊戲●●●

●新舊會員儲值就送500點

● 真人百家樂彩金等你拿

●線上影片直播、正妹圖、討論區免費註冊

歡迎免費體驗交流試玩!

●九州 娛樂 網站 http://ts777.cc

2015-05-04 23:56:22 · answer #2 · answered by Lawson 1 · 0 0

fedest.com, questions and answers