下載/瀏覽Download
Download
Report
Transcript 下載/瀏覽Download
計算機程式及實習
期末報告PPT製作
題目:豪爽飲料店結帳系統
南台科技大學
機械工程系
車輛一甲
學號:4A015055
學生:黃煜堯
老師:謝慶存
學習重點
ListBox、RadioButton的使用方法。
題目說明:飲料店結帳
設計結帳系統,填寫數量再按下計算鈕之後,即會顯示
結帳總金額。按「清除」按鈕,再輸入數量,並點選
「老客戶*0.9」,再按下「計算」鈕,得到打9折後的
那一筆總金額資料。
為程式加入加料5元功能,特別注意到是每一份
加料都必須加5元,而非不管訂多少份,加料都
只加5元。若總金額超過500元之單一筆訂單則
免收加飯費用功能,並請於畫面提示出此訊息。
實際操作
程式碼
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 = "累計:G$" & 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)
If total > 100 Then RadioButton3.Checked = True
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.75
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)
accTotal = accTotal - (Val(ListBox1.SelectedItem))
ListBox1.Items.RemoveAt(ListBox1.SelectedIndex)
Label7.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
Label6.Text = "$" & total & "元﹐"
End Sub
Private Sub ListBox1_MouseUp(ByVal sender As Object,
ByVal e As System.Windows.Forms.MouseEventArgs)
accTotal = accTotal - (Val(ListBox1.SelectedItem))
ListBox1.Items.RemoveAt(ListBox1.SelectedIndex)
Label7.Text = "累計→÷$" & accTotal & "元﹐"
End Sub
心得
Visual Basic在高中時候就已經有接觸過,不過
那還算是初學,在大學有更進階的接觸這入門
的程式製作軟體,因為VB的直覺性,讓剛接觸
程式製作的初學者也能輕易做出簡單的小程式,
而且指導老師上課也非常幽默又有趣,使原本
冰冷冷的程式碼也能有活潑的感覺,希望以後
也能夠更加練習可以做出更好的軟體出來。