字體:小 中 大 | |
|
|
2009/06/02 09:05:20瀏覽1870|回應52|推薦0 | |
現在我們將以一個實際運用的範例來做為Visual Basic程式語言的學習階段驗收! When you completed the work ! please build it to execute file and upload it to school network storage site and show me the link so i can check it! thanks! 表單設計如所附上的圖!請好好的看一下所運用到的物件!當然!程式碼我還是先附上給各位參考!但希望你現在應該具有基本的"閱讀"程式碼的功力了!可別還是停留在"文抄公"的階段!因為你應該具有閱讀別人程式碼的能力,才能夠進行修改程式碼,來符合功能要求!這樣才能由利用"範例"來撰寫一般標準的"視窗應用程式"的能力! Program code list(程式碼列表) 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 = "累計:$" & 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 > 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 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) Handles ListBox1.MouseUp accTotal = accTotal - (Val(ListBox1.SelectedItem)) ListBox1.Items.RemoveAt(ListBox1.SelectedIndex) Label7.Text = "累計:$" & accTotal & "元" End Sub End Class
|
|
( 知識學習|其他 ) |