Transcript 下載/瀏覽
計算機程式及實習
期末報告PPT製作
題目:JwK冰淇淋結帳系統
南台科技大學
機械工程系
車輛一甲
學號:4A015088
學生:鄭文凱
老師:謝慶存
學習重點
ListBox、RadioButton的使用方法。
題目說明:JwK冰淇淋店結帳
設計結帳系統,填寫數量再按下計算鈕之後,即會顯示
結帳總金額。按「清除」按鈕,再輸入數量,並點選
「買五*0.9」,再按下「計算」鈕,得到打9折後的那
一筆總金額資料。
為程式加入加長加5元功能,特別注意到是每一
份加長都必須加5元,而非不管訂多少份,加長
都只加5元。若總金額超過500元則打0.75折
實際操作
程式碼
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
心得
Visual Basic,算是初學,因為VB讓剛接觸
程式製作的初學者也能輕易做出簡單的小程式,
希望以後也能夠更加練習可以做出更好的軟體
出來。