80 likes | 230 Views
計算機程式及實習 商店 買賣程式. 班級 : 奈米一乙 學號 : 4A214073 姓名 : 葉豫銘. 題目說明. 運用這學期所學的 Visual Basic 20 10 語言撰寫程式 設計,設計出簡易的 商店買賣系統 ,擁有 3 種商品與 3 種折扣,價錢計算、總金額計算與詳細計算清單。 參考了範例圖示的表單設計與上課所學的程式設計,來完成這次的 Visual Basic 20 10 語言撰寫 。. 表單 (form) 設計. 程式碼撰寫. Public Class Form1 Private Property accTotal As Integer
E N D
計算機程式及實習商店買賣程式 班級:奈米一乙 學號:4A214073 姓名:葉豫銘
題目說明 運用這學期所學的Visual Basic 2010語言撰寫程式設計,設計出簡易的商店買賣系統,擁有3種商品與3種折扣,價錢計算、總金額計算與詳細計算清單。 參考了範例圖示的表單設計與上課所學的程式設計,來完成這次的Visual Basic 2010語言撰寫。
程式碼撰寫 Public Class Form1 Private Property accTotal As Integer Private Property total As Integer Private Property accTotal0 As String Private Sub CheckedListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) End Sub Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label1.Click End Sub
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.Black 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 > 5000 Then RadioButton3.Checked = True If RadioButton1.Checked = True Then total = total * 0.5 If RadioButton2.Checked = True Then total = total * 0.7 If RadioButton3.Checked = True Then total = total * 0.9 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 TextBox5_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TBoxPrice3.TextChanged End Sub Private Sub CheckBox2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) End Sub Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged 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 & "元" ListBox1.Items.Clear() Label7.Text = "累計:$" & 0 & "元" accTotal = Clear() End Sub Private Sub RadioButton2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton2.CheckedChanged End Sub Private Function Clear() As String End Function Private Sub GroupBox1_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GroupBox1.Enter End Sub Private Sub RadioButton1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton1.CheckedChanged End Sub End Class
心得感言及參考文獻 這次是第一次學習寫程式,想像中都是滿滿的程式碼,但其實還有表單讓整體設計簡易許多,其中還是有很多指令文字要記,在各種搭配下與副程式的出現,發現還是有許多困難之處,不過這次還是順利的成功了。 參考上課教的商店買賣程式與範例的表單設計