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

設計表單及程式,假設食品清單中,各樣食品的單價依序為25 10 10 20 25元,程式要提供下列功能
(1)在食品清單點選購買的食品,就顯示在品名右邊的方塊中,並自動顯示其單價
(2)輸入數量後,再按計算鈕,究計算及顯示金額
3.假如要讓上議題能夠連續處理多項食品的購買,最後在顯示總金額,要如何修改表單及程式
提示:可再表單上增加一個顯示總金額的標籤,及一個結帳的命令鈕,案此鈕,就轉被處理下一個客戶的資料
大家會的可以幫幫我嗎謝謝大家嚕^^

2006-03-03 17:13:12 · 1 個解答 · 發問者 泰迪熊 3 in 電腦與網際網路 軟體

1 個解答

'表單上置1個ListBox,Style屬性設為1;3個Label;1個CommandButton,自行調整好各元件大小及位置(Label1拉大一點)Dim A(4) As Integer, B As BooleanPrivate Sub Command1_Click()Dim I As IntegerB = TrueFor I = 0 To List1.ListCount - 1    List1.Selected(I) = False    A(I) = 0NextLabel1 = "": Label2 = "": Label3 = "": B = FalseEnd SubPrivate 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) = 25End WithLabel1 = "": Label2 = "": Label3 = ""Label1.WordWrap = TrueEnd SubPrivate Sub List1_Click()Dim S As String, I As Integer, T As IntegerIf B Then Exit SubWith List1    If .Selected(.ListIndex) Then       Do         S = InputBox("請輸入" & .Text & "購買數量:")         If S = "" Then .Selected(.ListIndex) = False: Exit Sub       Loop Until IsNumeric(S)       S = Abs(Int(S))       A(.ListIndex) = S       Label3 = .Text & "購買" & Int(S) & "個,合計:" & 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 IfEnd WithEnd Sub

2006-03-06 15:47:21 · answer #1 · answered by W.J.S. 7 · 0 0

fedest.com, questions and answers