《计算机程式及实习期末报告ppt制作.ppt》由会员分享,可在线阅读,更多相关《计算机程式及实习期末报告ppt制作.ppt(25页珍藏版)》请在三一办公上搜索。
1、計算機程式及實習期末報告ppt製作,南台科技大學機械工程系自控一乙學號:4A012045學生:陳俊吉任課老師:謝慶存,題目:臺灣高鐵訂票系統,臺灣高鐵訂票系統,學習重點Label、LinkLabel、MsgBox、PictureBox、RadioButton、TextBox、GroupBox的使用方法。,題目說明:臺灣高鐵訂票系統,票價計算方法:若高鐵從臺北起算,經由板橋、桃園、新竹、臺中、嘉義、臺南、到最後一站左營,票價分為別40、160、290、700、1080、1350及1490。將臺北站設為0,則任意二站價格相減,即為二站之間的票價。,程式中設了二個整數變數:price1為起站之價格,
2、price2是訖站之價格,點選站別後,上述的價格會分別設給這二個變數,在點選計算時將二變數相減再取絕對值。在Visual Basic中提供計算絕對值之寫法為:Math.abs(運算式),原價計算,按計算按鈕,會得到原價後一筆總金額資料。如在臺北按下起站,在桃園按下訖站,票價即出現原價之價格,自由座97折,按計算按鈕,並點選自由座97折,會自動得到打97折後一筆總金額資料。如在臺北按下起站,在桃園按下訖站,再選擇自由座97折,票價即出現原價之97折,早鳥優惠9折列車出發日前八日,按計算按鈕,並點選早鳥優惠9折,會自動得到打9折後一筆總金額資料。如在臺北按下起站,在桃園按下訖站,再早鳥優惠9折,票
3、價即出現原價之9折,按計算按鈕,並點選早鳥優惠7折,會自動得到打7折後一筆總金額資料。如在臺北按下起站,在桃園按下訖站,再早鳥優惠7折,票價即出現原價之7折,早鳥優惠7折列車出發日前十五日,連結臺灣高鐵網站,未按下前超連結文字預設為藍色,按下滑鼠左鍵不放開時設為紅色,超連結後文字設為橘色。本圖為按下滑鼠左鍵不放開時設為紅色之情況,按下結束,按下結束鍵後出現MsgBox對話方塊,若按下是Y,則離開程式畫面,若按下否N則又回到主畫面。,版面配置與屬性設定(上),起站GroupBox1,圖片PictureBox2,圖片PictureBox1,票價Label1,票價Textticket,訖站Group
4、Box2,Button1,RadioButton1RadioButton2RadioButton3RadioButton4RadioButton5RadioButton6RadioButton7RadioButton8,版面配置與屬性設定(下),RadioButton17RadioButton18RadioButton19,按鈕RadioButton9RadioButton10RadioButton11RadioButton12RadioButton13RadioButton14RadioButton15RadioButton16,限量發售GroupBox3,Button2,臺灣高鐵網站Lin
5、kLabel1,01Public Class Form102Dim price1 As Integer03Dim price2 As Integer04Dim quit As Integer05Dim result As MsgBoxResult06 Private Sub RadioButton1_CheckedChanged(ByVal sender As System.Object,ByVal e As System.EventArgs)Handles RadioButton1.CheckedChanged07price1=008 End Sub09 Private Sub RadioB
6、utton2_CheckedChanged(ByVal sender As System.Object,ByVal e As System.EventArgs)Handles RadioButton2.CheckedChanged10 price1=4011 End Sub12 Private Sub RadioButton3_CheckedChanged(ByVal sender As System.Object,ByVal e As System.EventArgs)Handles RadioButton3.CheckedChanged13 price1=16014 End Sub,程式碼
7、設計,15 Private Sub RadioButton4_CheckedChanged(ByVal sender As System.Object,ByVal e As System.EventArgs)Handles RadioButton4.CheckedChanged16 price1=29017 End Sub18 Private Sub RadioButton5_CheckedChanged(ByVal sender As System.Object,ByVal e As System.EventArgs)Handles RadioButton5.CheckedChanged19
8、 price1=70020 End Sub21 Private Sub RadioButton6_CheckedChanged(ByVal sender As System.Object,ByVal e As System.EventArgs)Handles RadioButton6.CheckedChanged22 price1=108023 End Sub24 Private Sub RadioButton7_CheckedChanged(ByVal sender As System.Object,ByVal e As System.EventArgs)Handles RadioButto
9、n7.CheckedChanged25 price1=135026 End Sub27 Private Sub RadioButton8_CheckedChanged(ByVal sender As System.Object,ByVal e As System.EventArgs)Handles RadioButton8.CheckedChanged28 price1=149029 End Sub,30 Private Sub RadioButton9_CheckedChanged(ByVal sender As System.Object,ByVal e As System.EventAr
10、gs)Handles RadioButton9.CheckedChanged31 price2=032 End Sub33 Private Sub RadioButton10_CheckedChanged(ByVal sender As System.Object,ByVal e As System.EventArgs)Handles RadioButton10.CheckedChanged34 price2=4035 End Sub36 Private Sub RadioButton11_CheckedChanged(ByVal sender As System.Object,ByVal e
11、 As System.EventArgs)Handles RadioButton11.CheckedChanged37 price2=16038 End Sub39 Private Sub RadioButton12_CheckedChanged(ByVal sender As System.Object,ByVal e As System.EventArgs)Handles RadioButton12.CheckedChanged40 price2=29041 End Sub42 Private Sub RadioButton13_CheckedChanged(ByVal sender As
12、 System.Object,ByVal e As System.EventArgs)Handles RadioButton13.CheckedChanged43 price2=70044 End Sub45 Private Sub RadioButton14_CheckedChanged(ByVal sender As System.Object,ByVal e As System.EventArgs)Handles RadioButton14.CheckedChanged46 price2=108047 End Sub,48 Private Sub RadioButton15_Checke
13、dChanged(ByVal sender As System.Object,ByVal e As System.EventArgs)Handles RadioButton15.CheckedChanged49 price2=135050 End Sub51 Private Sub RadioButton16_CheckedChanged(ByVal sender As System.Object,ByVal e As System.EventArgs)Handles RadioButton16.CheckedChanged52 price2=149053 End Sub54 Private
14、Sub RadioButton17_CheckedChanged(ByVal sender As System.Object,ByVal e As System.EventArgs)Handles RadioButton17.CheckedChanged55 Textticket.Text=Math.Abs(price1-price2)*0.9756 End Sub57 Private Sub RadioButton18_CheckedChanged(ByVal sender As System.Object,ByVal e As System.EventArgs)Handles RadioB
15、utton18.CheckedChanged58 Textticket.Text=Math.Abs(price1-price2)*0.959 End Sub60 Private Sub RadioButton19_CheckedChanged(ByVal sender As System.Object,ByVal e As System.EventArgs)Handles RadioButton19.CheckedChanged61 Textticket.Text=Math.Abs(price1-price2)*0.762 End Sub,63 Private Sub Button1_Clic
16、k(ByVal sender As System.Object,ByVal e As System.EventArgs)Handles Button1.Click64 Textticket.Text=Math.Abs(price1-price2)*0.9765 Textticket.Text=Math.Abs(price1-price2)*0.966 Textticket.Text=Math.Abs(price1-price2)*0.767 Textticket.Text=Math.Abs(price1-price2)68 End Sub69 Private Sub LinkLabel1_Li
17、nkClicked(ByVal sender As System.Object,ByVal e As)Handles LinkLabel1.LinkClicked70 LinkLabel1.LinkVisited=True71 LinkLabel1.VisitedLinkColor=Color.Orange72=tc)73 End Sub74 Private Sub Button2_Click(ByVal sender As System.Object,ByVal e As System.EventArgs)Handles Button2.Click75 quit=MsgBox(“是否結束?,
18、36,離開”)76 If(quit=MsgBoxResult.Yes)Then77 End 程式結束78 End If79 End Sub80 End Class,程式說明,第2、3行宣告金額的參數第4、5行宣告MsgBox變數來接受傳回值第6至8行將起站臺北訂為0元第9至11行將起站板橋訂為40元第12至14行將起站桃園訂為160元第15至17行將起站新竹訂為290元第18至20行將起站臺中訂為700元第21至23行將起站嘉義訂為1080元,程式說明續,第24至26行將起站臺南訂為1350元第27至29行將起站左營訂為1490元第30至32行將訖站臺北訂為0元第33至35行將訖站板橋訂為40
19、元第36至38行將訖站桃園訂為160元第39至41行將訖站新竹訂為290元第42至44行將訖站臺中訂為700元第45至47行將訖站嘉義訂為1080元,程式說明續,第48至50行將訖站臺南訂為1350元第51至53行將起站左營訂為1490元第54至56行將原價打97折之起站和訖站差之票價記至Textticket.Text中第57至59行將原價打9折之起站和訖站差之票價記至Textticket.Text中第60至62行將原價打7折之起站和訖站差之票價記至Textticket.Text中,程式說明續,第63至68行將滑鼠在Button1上點選時Textticket.Text會出現起站和訖站差之原價第
20、69至73行為超連結標籤的應用第74至80行為按下Button2按鈕,出現有提示訊息之輸出對話方塊,36代表MsgBox第4項按鈕代碼加上第32項警示圖示代碼,其按鈕格式碼等於4+32,按鈕代碼,警示圖示代碼,心得,這一次的程式設計確實相當不容易,製作過程中遇到不少的問題,有時候是程式碼少了一項宣告,有時候是按鈕按下後毫無反應,但不因此氣餒,想努力解決程式當中的錯誤,在反覆地修正調整後,終於可以正常的偵錯時,心情極度喜悅歡愉。最後也要感謝老師您上課用心的講解。,考文獻,1.Visual Basic 2005學習寶典,臺北:勁園圖書,20082.陳會安Visual Basic 2005程式設計範例教本,臺北:旗標,20093.廖文良學會寫程式Visual Basic2008,臺北:碁峯資訊,20094.蔡文龍Visual Basic2010基礎必修課,臺北:碁峯資訊,2011,