Transcript 下載/瀏覽
顏色茶飲結帳系統
班級:奈米一乙
學生:楊舒竣
學號:49914071
老師:謝慶存
結帳系統
設計此結帳系統,填
寫數量再按下計算鈕
之後,即會顯示結帳
總金額。按「清除」
按鈕,再輸入數量,
並點選「心情差打九
折」,再按下「計算」
鈕,得到打九折後的
那一筆總金額資料。
程式操作
更改數量按「計算」按鈕後,得到第1筆結
帳資料。
累計
可以知道今天你賣了多少茶賺多少錢
版面配置
茶飲
Label1
Label2
Label3
價錢
TBoxPrice1
TBoxPrice2
TBoxPrice3
數量
TBoxQty1
TBoxQty2
TBoxQty3
優待
GroupBox1
RadioButton1
RadioButton2
RadioButton3
你點的
ListBox1
Label6
Button1
Button2
程式碼
• Public Class Form1
•
Dim total, accTotal As Integer
• Private Sub Button2_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles Button2.Click
•
total = Val(TBoxPrice1.Text) * Val(TBoxQty1.Text) +
Val(TBoxPrice2.Text) * Val(TBoxQty2.Text) + Val(TBoxPrice3.Text)
* Val(TBoxQty3.Text)
•
If RadioButton1.Checked = True Then total = total * 0.9
•
If RadioButton2.Checked = True Then total = total * 0.8
•
If RadioButton3.Checked = True Then total = total * 0.7
•
Label6.Text = "$" & total & "元"
•
accTotal = accTotal + total
•
Label7.Text = "累計:$" & accTotal & "元"
•
ListBox1.Items.Add(total & "-->" & "黑茶" & TBoxPrice1.Text
& "*" & TBoxQty1.Text & "紫茶" & TBoxPrice2.Text & "*" &
TBoxQty2.Text & "灰茶" & TBoxPrice3.Text & "*" &
TBoxQty3.Text)
•
End Sub
• Private Sub Form1_Load(ByVal sender As
System.Object, ByVal e As System.EventArgs)
Handles MyBase.Load
•
Label6.Text = "$" & total & "元"
•
Label7.Text = "累計:$" & accTotal & "元"
•
Label6.Font = New Font("新細明體", 24)
•
Label6.ForeColor = Color.Red
•
total = 0
•
accTotal = 0
• End Sub
• Private Sub Button1_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs)
Handles Button1.Click
•
TBoxQty1.Text = 0
•
TBoxQty2.Text = 0
•
TBoxQty3.Text = 0
•
total = 0
•
Label6.Text = "$" & total & "元"
• End Sub
• Private Sub ListBox1_MouseUp(ByVal sender As
System.Object, ByVal e As
System.Windows.Forms.MouseEventArgs)
Handles Label6.MouseUp
•
accTotal = accTotal (Val(ListBox1.SelectedItem))
•
ListBox1.Items.RemoveAt(ListBox1.SelectedIndex)
•
Label7.Text = "累計:$" & accTotal & "元"
• End Sub
• End Class