下載/瀏覽

Download Report

Transcript 下載/瀏覽

南台飲料專賣店
班級:自控一甲
學號:49912054
學生:何宗哲
指導老師:謝慶存
目錄
學習重點
 題目說明
 版面配置屬性設定
 程式版面介紹
 程式碼
 成品操作方式

學習重點
1.學習製作程序。
2.ListBox、RadioButton的使用方法。
3.技巧要領。
4.程式代碼的涵義。
題目說明
設計一個快速結帳系統,讓自己點選
需要東西及輸入份量,就能迅速幫你
算出價錢,另外享有優惠的服務。
版面配置
屬性設定
冷飲
Label1
Label2
Label3
價格
TBoxPrice1
TBoxPrice2
TBoxPrice3
數量
TBoxQty1
TBoxQty2
TBoxQty3
加珍珠
CheckBox1
CheckBox2
CheckBox3
優待
GroupBox1
RadioButton1
RadioButton2
RadioButton3
列出點餐
ListBox1
金額
Lable9
Lable8
Button1
Button2
物件
TBoxPrice1
TBoxPrice2
TBoxPrice3
TBoxQty1
TBoxQty2
TBoxQty3
RadioButton1
RadioButton2
RadioButton3
Button1
Button2
ListBox1
屬性
Text
Text
Text
Text
Text
Text
Text
Text
Text
Text
Text
說明
青茶價格
紅/綠茶價格
奶茶價格
青茶數量
紅/綠茶數量
奶茶數量
南台生*0.95
自控一甲學生*0.9
>2000元*0.8
計算
清除
由程式控制
程式碼


Public Class Form1
Dim total, accTotal As Integer
Private Sub Form1_Load(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
MyBase.Load

Label9.Text = "$" & total & "元"

Label8.Text = "累計:$" & accTotal & "元"

Label9.Font = New Font("新細明體", 24)

Label9.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

total = Val(TBoxPrice1.Text) * Val(TBoxQty1.Text) +
Val(TBoxPrice2.Text) * Val(TBoxQty2.Text) +
Val(TBoxPrice3.Text) * Val(TBoxQty3.Text)

If total > 2000 Then RadioButton3.Checked = True

If RadioButton1.Checked = True Then total = total *
0.95

If RadioButton2.Checked = True Then total = total *
0.9

If RadioButton3.Checked = True Then total = total *
0.8

Label8.Text = "$" & total & "元"

accTotal = accTotal + total

Label8.Text = "累計:$" & accTotal & "元"

ListBox1.Items.Add(total & “-->” & “青茶” &
TBoxPrice1.Text & “*” & TBoxQty1.Text & “紅/綠茶” &
TBoxPrice2.Text & “*” & TBoxQty2.Text & “奶茶" &
TBoxPrice3.Text & "*" & TBoxQty3.Text)

Label9.Text = "$" & total & "元"

End Sub






Private Sub ListBox1_SelectedIndexChanged(ByVal sender
As System.Object, ByVal e As System.EventArgs) Handles
ListBox1.SelectedIndexChanged
accTotal = accTotal - (Val(ListBox1.SelectedItem))
ListBox1.Items.RemoveAt(ListBox1.SelectedIndex)
Label8.Text = "累計:$" & accTotal & "元"
End Sub







Private Sub Button2_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
Button2.Click
TBoxQty1.Text = 0
TBoxQty2.Text = 0
TBoxQty3.Text = 0
total = 0
End Sub
End Class
成品操作方式
1.試設計快餐店結帳系統,
填寫數量再按下計算鈕之後,
即會顯示結帳總金額。
按「清除」按鈕,
再輸入數量,
如果為南台生享有優惠
並點選「南台生*0.95」,
再按下「計算」鈕,
得到打95折後的
那一筆總金額資料。
2.按「清除」按鈕,清除剛剛的杯數,
再輸入茶飲的數量,
如果為自控一甲學生
享有優惠
並點選
「自控一甲學生*0.9」,
再按下「計算」鈕,
得到打9折後的
那一筆元資料。
超過2000元*0.8
3.發現因為超過2000元,
所以畫面中的>2000*0.8選項,
已經在程式運作下自動選取。