下載/瀏覽

Download Report

Transcript 下載/瀏覽

1
目錄
P1------封面
P2------目錄
P3------前言
P4------學習重點
P5------題目說明
P6------版面設計
P7------程式碼設計
P10----中文解釋
P12------製作心得
P13------參考文獻
2
前言
• 提出專題相關之背景,例如現存系統之功
能說明,可能包含的相關理論說明。詳細
說明程式的功能需求、相關參考資料、文
獻。
3
學習重點
•
•
•
•
ListBox、RadioButton的使用方法。
程式碼的編排
介面的設計
其他物件的認識
4
題目說明
能做出快速算
出所需的消費
金額。
而且可以有打
折的系統。
5
價格
Textbox1
Textbox2
Textbox3
食料總類(?
Label1
Label2
Label3
版面設計 加大
CheckBox1
數量
Textbox4
Textbox5
Textbox6
CheckBox2
CheckBox3
優惠方案
GroupBox1
RadioButton1
RadioButton2
RadioButton3
Button2
列出點餐
ListBox1
金額
Label6
Label7
Button1
6
程式碼設計
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
4. total = Val(TextBox1.Text) * Val(TextBox4.Text) +
Val(TextBox2.Text) * Val(TextBox5.Text) +
Val(TextBox3.Text) * Val(TextBox6.Text)
5. If total > 2000 Then RadioButton3.Checked = True
6. If RadioButton1.Checked = True Then total = total * 0.9
7. If RadioButton1.Checked = True Then total = total * 0.8
8. If RadioButton3.Checked = True Then total = total * 0.7
9. Label6.Text = "$" & total & "元"
10. accTotal = accTotal + total
7
11. Label7.Text = "累計:$" & accTotal & "元"
12. ListBox1.Items.Add(total & “-->” & “三杯皮蛋” &
TextBox1.Text & “*” & TextBox4.Text & “牡蠣咖哩” &
TextBox2.Text & “*” & TextBox4.Text & “燒烤金珍" &
TextBox3.Text & "*" & TextBox6.Text)
13. End Sub
14. Private Sub Button1_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
Button1.Click
15. TextBox4.Text = 0
16. TextBox5.Text = 0
17. TextBox6.Text = 0
8
18. total = 0
19. Label6.Text = "$" & total & "元“
20. End Sub
21. Private Sub ListBox1_SelectedIndexChanged(ByVal
sender As System.Object, ByVal e As System.EventArgs)
Handles ListBox1.SelectedIndexChanged
22. accTotal = accTotal - (Val(ListBox1.SelectedItem))
23. ListBox1.Items.RemoveAt(ListBox1.SelectedIndex)
24. Label7.Text = "累計:$" & accTotal & "元“
25. End Sub
26. End Class
9
中文解釋
• 第2行定義總金額及累計金額的參數。
• 第4行求出單筆交易的總金額。
• 第5行讓總金額>2000時RadioButton3 (即
>2000元*0.7鈕)自動選取。
• 第6-8行處理折扣動作。
• 第10行累加至累計金額。
• 第12行把單筆交易記錄至ListBox1中
10
• 第14-20行為「清除」按鈕的歸零動作。
• 第21-26行處理利用滑鼠在ListBox1上點選
時,放開滑鼠左鍵的刪除記錄動作。
– 第22行扣除該筆記錄在累加值中的數值。
– 第23行實際於ListBox1中刪除,刪除該筆記錄。
– 第24行把更正後的累加值,再度顯示出來。
11
製作心得
在這個學期中,雖然只學習到一些比較簡單的程式
製作。但是,這些就可以讓我們可以延伸應用了。
並且可以把其他的程式英文給學起來。
雖然打程式碼都看到有一點煩了,甚至是看到厭煩
了。但到了後來,自己在學習的途中,會突然開
竅。並且練習的速度會更快更容易理解。
最後,看到自己作完的完成檔。會有一種榮譽感。
因為自己以為做不出來,卻完成的那種喜悅感。
算是一種說不出來的暢快阿。
12
參考文獻
1.Visual Basic 2008基礎必修課(第二版 )
2.網路上的資源
13