Transcript 下載/瀏覽
姓名:黃崇瑋
班級:奈米四甲
學號:4a014030
老師:謝慶存
學習重點
ListBox、RadioButton兩系統的使用方式
將你所想要的神奇寶貝數量輸入,此系統會計算
出你所需花費金額以及計算你購買數量知方程式。
如果再Discount表單中點選”初心者”將會乘上0.8
的折扣,冒險家則乘0.7以此類推。
表單中買了5隻皮卡丘4隻妙蛙種子3隻卡比獸,價格分別為25000、
20000、35000。而下列Listbox表單有明確的計算出總價格。
而再Discount 中選取冒險家*0.7(RadioButton2)總價格將會乘上0.7
如總價超過500000,此系統會啟用”>500000*0.5”(RadioButton3)總價格將會乘上0.5
Label 1 2 3
Groupbox1
Radio Button 1 2 3
TextBoxPrice 1 2 3
Label 4 5
TextBoxQty1 2 3
Button 2 1
Listbox1
Label 6 7
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(TextBoxPrice1.Text) * Val(TextBoxQty1.Text) + Val(TextBoxPrice2.Text) * Val(TextBoxQty2.Text) +
Val(TextBoxPrice3.Text) * Val(TextBoxQty3.Text)
If total > 500000 Then RadioButton3.Checked = True
If RadioButton1.Checked = True Then total = total * 0.8
If RadioButton2.Checked = True Then total = total * 0.7
If RadioButton3.Checked = True Then total = total * 0.5
Label6.Text = "$" & total & "元"
accTotal = accTotal + total
Label7.Text = "累計:$" & accTotal & "元"
ListBox1.Items.Add(total & "-->" & "皮卡丘" & TextBoxPrice1.Text & "*" & TextBoxQty1.Text
& "妙蛙種子" & TextBoxPrice2.Text & "*" & TextBoxQty2.Text & "卡比獸" & TextBoxPrice3.Text & "*" & TextBoxQty3.Text)
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
TextBoxQty1.Text = 0
TextBoxQty2.Text = 0
TextBoxQty3.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
微軟出的VB系統,我覺得在各方面造福人群,讓民眾點點滑鼠就能輕而易舉的計算一些
不太好算的複雜數字,也非常感謝老師推崇這款軟體,此軟體不會很複雜,輕鬆就能了解研究。