120 likes | 317 Views
計算機程式及實習 期末報告 ppt 製作 題目 : 簡易車票系統. 南台科技大學 機械工程系 奈米一乙 學號 :4A214061 老師 : 謝慶存. 題目說明 : 主題說明與背景. 使用 MsgBox(),Button,if elseif 語法 ,rdb 控制鍵. 題目說明 : 主題說明與背景. 先選擇票種在選擇出發地 , 假設沒有先選擇票種而先選出發地 , 則會出現 MsgBox. 程式碼撰寫 : 語言程式之實作方法 -1. Public Class Form1 Dim tick As Integer Dim A As Boolean
E N D
計算機程式及實習 期末報告ppt製作 題目:簡易車票系統 南台科技大學 機械工程系 奈米一乙 學號:4A214061 老師:謝慶存
題目說明:主題說明與背景 • 使用MsgBox(),Button,if elseif語法,rdb控制鍵
題目說明:主題說明與背景 先選擇票種在選擇出發地,假設沒有先選擇票種而先選出發地,則會出現MsgBox
程式碼撰寫:語言程式之實作方法-1 Public Class Form1 Dim tick As Integer Dim A As Boolean Dim B As Boolean Dim C As Boolean Dim X As Boolean Private Sub btnA_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnA.Click If X = False Then MsgBox("請先選擇票種", MsgBoxStyle.DefaultButton1, "錯誤") Else GroupBox2.Visible = True btnX.Text = "高雄" btnY.Text = "路竹" A = True End If End Sub
Private Sub btnB_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnB.Click If X = False Then MsgBox("請先選擇票種", MsgBoxStyle.DefaultButton1, "錯誤") Else GroupBox2.Visible = True btnX.Text = "鳳山" btnY.Text = "路竹" B = True End If End Sub Private Sub btnC_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnC.Click If X = False Then MsgBox("請先選擇票種", MsgBoxStyle.DefaultButton1, "錯誤") Else GroupBox2.Visible = True btnX.Text = "鳳山" btnY.Text = "高雄" C = True End If End Sub Private Sub Form1_Activated(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Activated btnA.Text = "鳳山" btnB.Text = "高雄" btnC.Text = "路竹" GroupBox2.Visible = False ltbTick.Text = "" End Sub
Private Sub btnX_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnX.Click If A = True Then tick = 20 ltbTick.Text = tick End If If B = True Then tick = 20 ltbTick.Text = tick End If If C = True Then tick = 50 ltbTick.Text = tick End If If rdbOld.Checked = True Then Label1.Text = "優惠價:" ltbTick.Text = tick * 0.9 End If End Sub Private Sub btnY_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnY.Click If A = True Then tick = 50 ltbTick.Text = tick End If If B = True Then tick = 30 ltbTick.Text = tick End If If C = True Then tick = 30 ltbTick.Text = tick End If
If rdbOld.Checked = True Then • Label1.Text = "優惠價:" • ltbTick.Text = tick * 0.9 • End If • End Sub • Private Sub rdbNormal_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rdbNormal.CheckedChanged • X = True • End Sub • Private Sub rdbOld_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rdbOld.CheckedChanged • X = True • End Sub • End Class
程式開始畫面 先選擇普通票種,再選擇鳳山
程式畫面 • 當按下鳳山時,目的地選項就不會有鳳山
程式畫面 按下優待票種,再按下高雄,再點路竹,顯示優惠價27元
票價內容 當票種選優待時,票價會自己打九折
心得感言 剛開學一開始觸碰VB,覺得這程式好難,看老師操作也覺得好複雜,不過老師做出來的成品好酷,感覺好好玩! 之後自己在課堂操作時,根本狀況一堆,後來因為同學的幫忙,好讓我可以跟上軌道,也知道VB有多好玩