下載/瀏覽Download
Download
Report
Transcript 下載/瀏覽Download
計算機程式及實習
期末報告ppt製作
噴水麻麻店結帳系統之客人爽ㄏㄏ
南台科技大學
機械工程系
奈米一乙
學號:4A014084
老師:謝慶存
麻麻店結帳
可以設計麻麻店結帳系統,填寫
數量在按下計算鈕之後,即會顯
示結帳總金額‧按「清除」按鈕,
在輸入數量,並點選「老男人
*0.77」,再按下「計算」鈕,得
到打0.77折後的那一筆總金額資
料‧
程式展示
設定噴汁雞肉飯=5 按下【計算金額】即得到資料
設定噴水雞肉飯數量2加飯,
噴火雞肉飯數量三,愛約戶*0.66
噴汁雞肉飯數量五。
按下計算金額即可得到$416元的結果
假設剛剛那筆416是錯誤的,那點擊項目
他就會自動刪除並且從總金額扣去
按下清除就會清除全部資料,並且將金額歸零
表單物件
屬性設置
快餐
Label1
Label2
Label3
列ListBox1
價格
TBoxPrice1
TBoxPrice2
TBoxPrice3
數量
TBoxQty1
TBoxQty2
TBoxQty3
加飯
CheckBox1
CheckBox2
CheckBox3
優待GroupBox1
RadioButton1
RadioButton2
RadioButton3
Button2
金額
Label6
Label7
Button1
物件
屬性
設定
說明
TBoxPrice1 Text
“”
噴水雞肉飯價格
TBoxPrice2 Text
“”
噴火雞肉飯價格
TBoxPrice3 Text
“”
噴汁雞肉飯價格
TBoxQty1 Text
噴水雞肉飯數量
TBoxQty2 Text
噴火雞肉飯數量
TBoxQty3 Text
噴汁雞肉飯數量
RadioButto
n1
Text
老男人*0.77
RadioButton
2
Text
愛約戶*0.66
RadioButton
3
Text
常客*0.5
Button1
Text
清除
Button2
Text
計算
ListBox1
由程式控制
程式碼設計
1
2
3
4
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles MyBase.Load
5
Label6.Text = "$" & total & "元﹐"
6
Label7.Text = "累O計p:G$" & accTotal & "元﹐"
7
Label6.Font = New Font("新Ps細O明u體e", 24)
8
Label6.ForeColor = Color.Red
9
total = 0
10
accTotal = 0
11
Public Class Form1
Dim total1, total2, total3 As Integer
Dim total, accTotal As Integer
End Sub
程式碼設計
12
13
total = Val(TBoxPrice1.Text) * Val(TBoxQty1.Text) + Val(TBoxPrice2.Text) * Val(TBoxQty2.Text) +
Val(TBoxPrice3.Text) * Val(TBoxQty3.Text)
14
15
16
17
18
19
20
21
22
If total < 500 Then
If CheckBox1.Checked Then total1 = (Val(TBoxPrice1.Text) + 5) * Val(TBoxQty1.Text)
If CheckBox2.Checked Then total2 = (Val(TBoxPrice2.Text) + 5) * Val(TBoxQty2.Text)
If CheckBox3.Checked Then total3 = (Val(TBoxPrice3.Text) + 5) * Val(TBoxQty3.Text)
If CheckBox1.Checked = False Then total1 = (Val(TBoxPrice1.Text)) * Val(TBoxQty1.Text)
If CheckBox2.Checked = False Then total2 = (Val(TBoxPrice2.Text)) * Val(TBoxQty2.Text)
If CheckBox3.Checked = False Then total3 = (Val(TBoxPrice3.Text)) * Val(TBoxQty3.Text)
total = total1 + total2 + total3
End If
23
If RadioButton1.Checked = True Then total = total * 0.77
24
If RadioButton2.Checked = True Then total = total * 0.66
25
If RadioButton3.Checked = True Then total = total * 0.5
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
程式碼設計
26
Label6.Text = "$" & total & "元﹐"
27
accTotal = accTotal + total
28
Label7.Text = "累O計p:G$" & accTotal & "元﹐"
29
ListBox1.Items.Add(total & "-->" & "噴Q水o" & TBoxPrice1.Text & "*" &
TBoxQty1.Text & "噴Q火o" & TBoxPrice2.Text & "*" & TBoxQty2.Text & "噴Q汁DA" &
TBoxPrice3.Text & "*" & TBoxQty3.Text)
30
End Sub
31
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
程式碼設計
32
33
TBoxQty2.Text = 0
34
TBoxQty3.Text = 0
35
total = 0
36
Label6.Text = "$" & total & "元﹐"
37
38
Private Sub ListBox1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles
ListBox1.MouseUp
39
accTotal = accTotal - (Val(ListBox1.SelectedItem))
40
ListBox1.Items.RemoveAt(ListBox1.SelectedIndex)
41
Label7.Text = "累O計p:G$" & accTotal & "元﹐"
42
43
TBoxQty1.Text = 0
End Sub
End Sub
End Class
程式說明
第2-3行定意總金額即累計金額的參數
第5-10行設定開啟程式時金額及總金額為零元
第13行計算單筆交易總金額
第14-22行處理超過五百元加飯免錢的運算
第23-25行進行折扣處理
第26-29行負責資料顯示及總金額的計算和顯示
第32-36行負責將資料全部歸零
第39-41行進行單筆資料刪除
報告心得
Visual Basic 真是有夠難,因為它的介面不好,在邏
輯方面就毫無概念, Visual Basic 的介面卻乏中文解
釋,這次老師叫我們設計真是要了我的命,幸好皇
天不負苦心人,終於讓我在最後一刻解決問題,謝
謝老師給予我們這麼有難度的作業,好讓我知道沒
學到的還很多,感謝老師辛苦教學,希望老師分數
可以給的漂亮一點,我會認真學好程式,寫出更多
好玩有趣的程式,才不會辜負老濕的期望,最後謝
謝老師的
耐心的教導,請受我一拜!
參考文獻
Visual Basic 2010基礎必修課 碁峰 2010
林義証、蔡文龍、張傑瑞、何叡 著