Presentation is loading. Please wait.

Presentation is loading. Please wait.

計算機程式及實習 期末報告 題目:商店結帳系統

Similar presentations


Presentation on theme: "計算機程式及實習 期末報告 題目:商店結帳系統"— Presentation transcript:

1 計算機程式及實習 期末報告 題目:商店結帳系統
南台科技大學 機械工程系 自控三甲 姓名:許恩慈 學號:4a 指導老師:謝慶存

2 學習重點 Label、Button 、 ListBox、RadioButton 、 GroupBox的使用方法。 程式碼的編輯。

3 題目說明:商店結帳系統 設計商店結帳系統,填寫數量再按下計算鈕之後,即會顯示結帳總金額。
按「清除」按鈕,再輸入數量,並點「VIP* 0.8」,再按下「計算」鈕,得到打8折後的那一筆總金額資料。 按下顯示時間,會顯示現在時間。

4 程式介紹-改蝦仁炒飯數量 改蝦仁炒飯數量為1按「計算」按鈕後,得到第1筆結帳資料。

5 再輸入肉絲炒飯的數量為2 按「清除」按鈕,清除剛剛的蝦仁炒飯一份後,再輸入雞肉飯的數量為二,並點選「VIP *0.8 」,再按下「計算」鈕,得到打8折後的那一筆80元資料。

6 超過2000元*0.75 在什錦炒飯旁的數量欄中輸入50並按下「計算」鈕。
發現因為超過2000元,所以畫面中的>2000*0.75選項,已經在程式運作下自動選取。

7 顯示時間 按下顯示時間,就會顯示現在的時間及日期。

8 版面配置屬性設定 列出點餐 ListBox1 價格 數量 TextBox1 TextBox4 TextBox2 TextBox5
價格 數量 TextBox1 TextBox4 TextBox2 TextBox5 TextBox3 TextBox6 Button1 Button2 炒飯 Label1 Label2 Label3 優待 GroupBox1 RadioButton1 RadioButton2 RadioButton3 Label4 Label5 金額 Label7 Label8 Label6 Button3

9 物件屬性設定說明 物件 屬性 設定 說明 TextBox1 Text “” 什錦炒飯價格 TextBox2 肉絲炒飯價格 TextBox3
蝦仁炒飯價格 TextBox4 什錦炒飯數量 TextBox5 肉絲炒飯數量 TextBox6 蝦仁炒飯數量

10 物件屬性設定說明 物件 屬性 設定 說明 RadioButton1 Text 老客戶*0.9 RadioButton2 VIP*0.8
>2000元*0.75 Button1 計算 Button2 清除 Button3 顯示時間 ListBox1 由程式控制

11 程式碼設計 1 Public Class Form1 2 Dim total, accTotal As Integer
3 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Label7.Text = "$" & total & "元" Label8.Text = "累計:$" & accTotal & "元" Label7.Font = New Font("新細明體", 24) Label7.ForeColor = Color.Red total = 0 accTotal = 0 10 End Sub

12 程式碼設計 11 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click total = Val(TextBox1.Text) * Val(TextBox4.Text) + Val(TextBox2.Text) * Val(TextBox5.Text) + Val(TextBox3.Text) * Val(TextBox6.Text) If total > 2000 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

13 程式碼設計 17 Label7.Text = "$" & total & "元"
accTotal = accTotal + total Label8.Text = "累計:$" & accTotal & "元" ListBox1.Items.Add(total & "-->" & "什錦炒飯" & TextBox1.Text & "*" & TextBox4.Text & "肉絲炒飯" & TextBox2.Text & "*" & TextBox5.Text & "蝦仁炒飯" & TextBox3.Text & "*" & TextBox6.Text) 21 End Sub

14 程式碼設計 22 Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click TextBox4.Text = 0 TextBox5.Text = 0 TextBox6.Text = 0 total = 0 Label7.Text = "$" & total & "元" 28 End Sub

15 程式碼設計 29 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 & "元" 33 End Sub

16 程式碼設計 34 Private Sub Label6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label6.Click Label6.Text = Now 36 End Sub 37 Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click Label6.Text = Now() 39 End Sub 40 End Class

17 程式說明 第2行定義總金額及累計金額的參數。 第12行求出單筆交易的總金額。
第13行讓總金額>2000時RadioButton3 (即>2000元*0.75鈕)自動選取。 第14-16行處理折扣動作。 第18行累加至累計金額。 第20行把單筆交易記錄至ListBox1中。 第22-28行為「清除」按鈕的歸零動作。

18 程式說明 第29-33行處理利用滑鼠在ListBox1上點選時,放開滑鼠左鍵的刪除記錄動作。 第30行扣除該筆記錄在累加值中的數值。
第32行把更正後的累加值,再度顯示出來。 第34-39行為顯示現在時間和日期。

19 心得 從來沒有想過幾個簡單的程式碼,就能完成一個系統或者一個小遊戲,非常謝謝老師在這學期教導我們VB程式的應用,對初學者來說還是遇到不少困難,希望能越挫越勇,從哪裡跌倒就從哪裡爬起來!當自己努力完成一個程式時,真的是無比的開心,越來越覺得這程式很有趣一點都不煩悶!一開始以為很簡單,實際上操作卻是有難度的,任何東西真的都要試試看才知道,最後還是謝謝老師用心不嫌麻煩的教導我們。

20 參考文獻 Visual Basic 2010 基礎必修課 著作:林義證 蔡文龍 張傑瑞 河叡 策劃:吳明哲 出版社:碁峯

21 The End 謝謝老師的教導


Download ppt "計算機程式及實習 期末報告 題目:商店結帳系統"

Similar presentations


Ads by Google