下載/瀏覽

Download Report

Transcript 下載/瀏覽

阿低麵店
班級:自控一甲
學號:49912016
學生:卓玄坤
指導老師:謝慶存
目錄
學習重點
 題目說明
 版面配置屬性設定
 程式版面介紹
 程式碼
 成品操作方式

學習重點
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.9
附近居民*0.85
>1000元*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 > 1000 Then RadioButton3.Checked = True

If RadioButton1.Checked = True Then total = total
0.90

If RadioButton2.Checked = True Then total = total *
0.85

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.90」,
再按下「計算」鈕,
得到打9折後的
那一筆總金額資料。
2.按「清除」按鈕,清除剛剛的杯數,
再輸入茶飲的數量,
如果為附近居民
享有優惠
並點選
「附近居民*0.85」,
再按下「計算」鈕,
得到打85折後的
那一筆元資料。
超過1000元*0.8
3.發現因為超過1000元,
所以畫面中的>1000*0.8選項,
已經在程式運作下自動選取。