下載/瀏覽

Download Report

Transcript 下載/瀏覽

班級:車輛一甲
學號:4A115088
姓名:吳紹瑀
指導老師:謝慶存老師
車輛專屬瘦身房結帳程式說明
 學習重點:
 使用Visual Basic 2010
 熟練有關Button Lable
ListBox 的運用
在想要哪個瘦身內容裡填
寫幾小時,另外滿幾小時
會多送特別服務,如果持
有本店會員,有打折的服
務,如果消費金額超過額
度,另有打折優惠
文件說明
價格
TBoxPrice1
TBoxPrice2
TBoxPrice3
Lable1
Lable2
Lable3
列出餐點
ListBox1
使用小時
額外服務
TBoxQty1
TBoxQty1
TBoxQty1
CheceBox1
優惠方案
GroupBox1
RadioButton1
RadioButton2
RadioButton3
金額
Lable6
Lable7
程式碼設計
 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
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
total = Val(TBoxPrice1.Text) * Val(TBoxQty1.Text) +
Val(TBoxPrice2.Text) * Val(TBoxQty2.Text) + Val(TBoxPrice3.Text) *
Val(TBoxQty3.Text)
Dim total1, total2, total3, accTotal As Integer
If total > 1000000 Then CheckBox1.Checked = True
If CheckBox1.Checked Then total1 = (Val(TBoxPrice1.Text) *
Val(TBoxQty1.Text)) + (Val(CheckBox1.Text))
If CheckBox1.Checked Then total2 = (Val(TBoxPrice2.Text) *
Val(TBoxQty2.Text)) + (Val(CheckBox1.Text))
If CheckBox1.Checked Then total3 = (Val(TBoxPrice3.Text) *
Val(TBoxQty3.Text)) + (Val(CheckBox1.Text))
If Not CheckBox1.Checked Then total1 = (Val(TBoxPrice1.Text) *
Val(CheckBox1.Text))
If Not CheckBox1.Checked Then total2 = (Val(TBoxPrice2.Text) *
Val(CheckBox1.Text))
If Not CheckBox1.Checked Then total3 = (Val(TBoxPrice3.Text) *
Val(CheckBox1.Text))
total = total
 If total > 2000000 Then RadioButton4.Checked = True

If RadioButton1.Checked = True Then total = total *
0.9

0.8

0.6

0.5




If RadioButton2.Checked = True Then total = total *
If RadioButton3.Checked = True Then total = total *
If RadioButton4.Checked = True Then total = total *
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 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
Label6.Text = "$" & total & "元"
End Sub
Private Sub ListBox1_MouseUp(ByVal sender As Object,
ByVal e As System.Windows.Forms.MouseEventArgs)
Handles ListBox1.MouseUp
accTotal = accTotal - (Val(ListBox1.SelectedItem))
ListBox1.Items.RemoveAt(ListBox1.SelectedIndex)
Label7.Text = "累計:$" & accTotal & "元"
End Sub
心得
這是我第一次接觸Visual Basic ,一開始什麼都
不懂,對程式碼完全摸不著頭緒,但經過老師用
心的教導,終於有一些底子了,在學會怎麼設計
程式碼之後,親手完成了這一個程式心裡覺得很
開心,或許這次的作品並不是最好,但至少是用
心做出來的!!!!
老師謝謝您用心的教導~~~辛苦了!!!
參考文獻
 isual Basic2010基礎必修課
 林 義証、蔡文龍、張傑瑞、何叡 著
 吳 明哲 策劃