下載/瀏覽Download
Download
Report
Transcript 下載/瀏覽Download
計算機程式及實習
期末報告ppt製作
題目:喝到飽飲料店結帳系統
南台科技大學
機械工程系
車輛一乙
學號:4A015085
學生:蔡傑勛
指導老師:謝慶存
學習重點
• ListBox、TextBox、RadioButton的使用方
法。
題目說明:喝到飽飲料店結帳系統
試設計喝到飽飲料店結帳系統,
填寫數量再按下計算鈕之後,
即會顯示結帳總金額。
按「清除」按鈕,再輸入數量,
並點選「會員*0.9」或者是,
「滿一千*0.8」再按下「計算」,
得到打9折或8折的那一筆總金額資料。
顧名思義喝到飽飲料店,
加波霸不用錢只給勾選用。
程式開始畫面-改綠茶數量
• 改綠茶數量為10按「結帳」按鈕後,得到
結帳資料。
程式開始畫面-改紅茶數量
• 刪除綠茶數量改紅茶數量為10按「結帳」
按鈕後,得到結帳資料。
程式開始畫面-改奶茶數量
• 刪除紅茶改奶茶數量為10按「結帳」按鈕
後,得到結帳資料。
程式開始畫面-改冬瓜茶數量
• 刪除奶茶改冬瓜數量為10按「結帳」按鈕
後,得到結帳資料。
超過1000元*0.8
• 在綠茶旁的數量欄中輸入100並按下「計算」
鈕。發現因為超過1000元,所以畫面中的
>1000*0.8選項,已經在程式運作下自動選取。
會員*0.9
• 有會員證可以享有0.9折優惠,要自行選取
加波霸真的不加價
有加
沒加
方便加減系統
假設450元這筆資料是客人叫錯的,
必須刪除掉。使用者只需直接以滑鼠
點選這筆資料,不用在全部刪除全部
重來,這筆資料就會自動被刪除,同
時,累計值會自動把這筆資料的450元,
從累計金額中扣除。
Label1
Label5
Label6
Label7
Label10
CheckBox1
CheckBox2
CheckBox3
CheckBox4
Label2
Label3
TextBox1 TextBox5
Label4
TextBox2 TextBox6
ListBox1
Label8
TextBox3 TextBox7
RadioButton1
TextBox4 TextBox8
RadioButton2
Label9
Button2
Button1
程式碼設計
1 Public Class Form1
2 Dim total, accTotal As Integer
3 Private Sub Form1_Load(ByVal sender As
System.Object, ByVal e As System.EventArgs)
Handles MyBase.Load
4 Label8.Text = "$" & total & "元﹐"
5 Label9.Text = "累計:$" & accTotal & "元﹐"
6 total = 0
7 accTotal = 0
8 End Sub
9 Private Sub ListBox1_MouseUp(ByVal sender As Object,
ByVal e AsSystem.Windows.Forms.MouseEventArgs)
Handles
12 ListBox1.MouseUp
13 accTotal = accTotal - (Val(ListBox1.SelectedItem))
14 ListBox1.Items.RemoveAt(ListBox1.SelectedIndex)
15 Label9.Text = "累計:$" & accTotal & "元﹐"
16 End Sub
17 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
18 total = Val(TextBox1.Text) * Val(TextBox5.Text) + Val(TextBox2.Text) *
Val(TextBox6.Text) + Val(TextBox3.Text) * Val(TextBox7.Text) +
Val(TextBox4.Text) * Val(TextBox8.Text)
19 If total > 1000 Then RadioButton2.Checked = True
20 If RadioButton1.Checked = True Then total = total * 0.9
21 If RadioButton2.Checked = True Then total = total * 0.8
22 Label8.Text = "$" & total & "元﹐"
23 accTotal = accTotal + total
24 Label9.Text = "累計:$" & accTotal & "元﹐"
25 ListBox1.Items.Add(total & "-->" & "綠茶" & TextBox1.Text & "*" &
TextBox5.Text & "紅茶" & TextBox2.Text & "*" & TextBox6.Text & "奶茶"
& TextBox3.Text & "*" & TextBox7.Text & "冬瓜茶" & TextBox4.Text &
"*" & TextBox8.Text)
26 End Sub
27 Private Sub Button2_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs)
Handles Button2.Click
28 TextBox5.Text = 0
29 TextBox6.Text = 0
31 TextBox7.Text = 0
32 TextBox8.Text = 0
33 total = 0
34 Label8.Text = "$" & total & "元﹐"
35 End Sub
第2點宣告總金額及累計金額的參數。
第13-15行利用滑鼠在ListBox1上點選時,放
開滑鼠左鍵的刪除記錄動作。
第18行計算單筆交易的總金額。
第19行讓總金額>1000時RadioButton2 (即
>1000元*0.8鈕)自動選取。
第20~21行執行折扣。
第23行累計金額。
第25行把單筆交易記錄至ListBox1中。
第28-33行結帳完畢可以清除所有數量,總金
額。
心得
Visual Basic 第一次接觸,因為平常就有用
程式的習慣,在寫程式就大概知道Visual
Basic 課本寫的很詳細,但是在寫腳本過程
中遇到了不少的問題,想很多辦法去解決想不
出來真的快發瘋了,想出來就很爽。
參考文獻
Visual Basic課本
老師的範本
知識家
呵呵~