題目:台灣客運 南臺科技大學 機械工程系 班級:奈米一乙 學號:4A314082 姓名:蔡政堯 授課教師:謝慶存 計算機程式及實習 期末報告 題目:台灣客運 南臺科技大學 機械工程系 班級:奈米一乙 學號:4A314082 姓名:蔡政堯 授課教師:謝慶存
學習重點 Label、LinkLabel、MsgBox、PictureBox、RadioButton、TextBox、GroupBox的使用方法
版面配置 優惠 GroupBox3 RadioButton17 RadioButton18 RadioButton19 起點
版面配置 終點 GroupBox2 RadioButton9 RadioButton10 RadioButton11 確定 Button1 TextBox1 計算 Label1 離開 Button2
程式碼 Public Class Form1 Dim price1 As Integer Dim price2 As Integer Dim quit As Integer Dim result As MsgBoxResult Private Sub RadioButton1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton1.CheckedChanged price1 = 0 End Sub Private Sub RadioButton2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton2.CheckedChanged price1 = 60 Private Sub RadioButton3_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton3.CheckedChanged price1 = 125 Private Sub RadioButton4_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton4.CheckedChanged price1 = 245
程式碼 Private Sub RadioButton5_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton5.CheckedChanged price1 = 305 End Sub Private Sub RadioButton6_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton6.CheckedChanged price1 = 405 Private Sub RadioButton7_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton7.CheckedChanged price1 = 505 Private Sub RadioButton8_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton8.CheckedChanged price1 = 545 Private Sub RadioButton9_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton9.CheckedChanged price2 = 0 Private Sub RadioButton10_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton10.CheckedChanged price2 = 60
程式碼 Private Sub RadioButton11_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton11.CheckedChanged price2 = 125 End Sub Private Sub RadioButton12_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton12.CheckedChanged price2 = 245 Private Sub RadioButton13_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton13.CheckedChanged price2 = 305 Private Sub RadioButton14_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton14.CheckedChanged price2 = 405 Private Sub RadioButton15_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton15.CheckedChanged price2 = 505 Private Sub RadioButton16_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton16.CheckedChanged price2 = 545
程式碼 Private Sub RadioButton17_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton17.CheckedChanged TextBox1.Text = Math.Abs(price1 - price2) * 0.8 End Sub Private Sub RadioButton18_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton18.CheckedChanged TextBox1.Text = Math.Abs(price1 - price2) * 0.55 Private Sub RadioButton19_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton19.CheckedChanged TextBox1.Text = Math.Abs(price1 - price2) * 0.45 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click ' Textticket.Text = Math.Abs(price1 - price2) * 0.8 ' Textticket.Text = Math.Abs(price1 - price2) * 0.55 ' Textticket.Text = Math.Abs(price1 - price2) * 0.45 TextBox1.Text = Math.Abs(price1 - price2) Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click quit = MsgBox("是否結束?", 36, "離開") If (quit = MsgBoxResult.Yes) Then End '程式結束 End If Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load Private Sub GroupBox1_Enter(sender As Object, e As EventArgs) Handles GroupBox1.Enter End Class
心得 雖然之前在高職學過Visual Basic,但是那時只有學到一些基礎東西而已。不過在大學老師這學期教我們這多VB程式的應用,讓我們了解更多,能設計出更多更不同的東西,雖然這是簡單的基礎VB運用,但是在製作這程式過程當中遇到了不少的問題,不過還是努力的想要去解決這些問題,然後解決之後就變得很有成就感,最後很感謝老師在這學期認真的教導。
參考資料 蔡文龍《Visual Basic2013基礎必修課》