Transcript 下載/瀏覽
主題:飯的主題餐廳
台南科技大學
機械工程系自動控制組
學生:曹程皓
班級:甲班
學號:49912059
目錄
學習重點
版面設計流程
設計解析
屬性設定
程式設計
心得
學習重點
學習程式設計
練習計算轉換程式
設計一個有用的程式
版面設計流程
先新增8個Label、6個TextBox、4個RadioBox、3個
CheckBox、2個Button、1個ListBox、1個GroupBox,
之後開始設計程式,
至於內容有好吃的飯
,因為學校外面有一
家餐廳的菜單上有,
由於特別,所以有此
設計相關內容。
設計解析1.
將寫好的程式偵錯,完成後開始測試,先設定
高級的飯10份+好吃的飯10份,購買者為民眾,
最後總金額為1800。
設計解析2.
再來是測試高級的飯10份+好吃的飯10份,購買者為南
台的學生,由於南台學生可愛活潑,店家給9折優惠,
最後總金額為1620。
設計解析3.
這次定了20份高級的飯,由於老闆常看見伯伯三餐都在
他們店裡出現,所以被定為老顧客名單打了他95折優惠,
總金額為1900。
設計解析4.
這是伯伯買了20份高級的飯,因為婆婆也餓了,伯伯
幫她點了好吃的飯,店家看見伯伯又來彭場,還是給
他95折優惠,算出來
因該是1976元,正因
為是大於2000元,所
以真正的金額為1768
元,老闆太高興給他
85折。
屬性設定
單位
TextBox1
TextBox2
TextBox3
TextBox4
TextBox5
TextBox6
文字
Label1、Label2
Label3、Label4
Label5、Label6
Label7、Label8
加飯
CheckBox1
CheckBox2
CheckBox3
優待
RadioBox1
RadioBox2
RadioBox3
RadioBox4
按鍵
Button1
Button2
表單
ListBox1
程式設計
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.95
If RadioButton2.Checked = True Then total = total * 0.9
If RadioButton3.Checked = True Then total = total * 0.85
If RadioButton4.Checked = True Then total = total * 1
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 System.Object, ByVal e As
System.EventArgs) Handles ListBox1.MouseUp
acctotal = acctotal - (Val(ListBox1.SelectedItem))
ListBox1.Items.RemoveAt(ListBox1.SelectedIndex)
Label7.Text = "累計:$" & acctotal & "元"
End Sub
End Class
實際照片
心得
這次是第一次接觸VisualBasic的程式設計,剛開始什
麼都不太會,幾乎都要透過老師ㄧ一講解才能明白這
些指令是做什麼用的,每次教的東西都不大一樣,學
的東西越來越多,實力也是一點一滴,慢慢的累積出
來,每次遇到困難的時候,只要舉手,老師ㄧ定衝過
來問;怎麼了? 哪裡不會,老師實在是太可愛了,讓
學生们又愛又恨的,在學習的過程中,時而嚴肅時而
歡樂,我覺得老師拿捏的恰到好處,這是我喜歡上他
課的原因。