Beruflich Dokumente
Kultur Dokumente
BuildingtheDirectionsApplication
Step1
Definewhattheapplicationistodo Purpose:DisplayamaptotheHighlanderHotel Input:None Process:Displayaform Output:Displayontheformagraphicimageshowingamap
Step2
VisualizetheApplicationandDesignItsUserInterface
Page1of11
KnowledgeSystemsInstituteGraduateSchoolCIS310IntroductiontoProgramming(VisualBasic) BuildingtheDirectionsApplication
Step3
Determinethecontrolsneeded
Step4
Definerelevantpropertyvaluesforeachcontrol Form o o Name:Form1 Text:"Directions"
Page2of11
Runtheapplication Closeandsavetheapplication
Page3of11
KnowledgeSystemsInstituteGraduateSchoolCIS310IntroductiontoProgramming(VisualBasic) BuildingtheDirectionsApplication
ModifytheDirectionsApplication
TheHighlanderHotelmanagerwouldlikeyoutoaddthefollowingitemstotheapplication: ALabelcontainingthewrittendirections AButtontodisplaythedirections AButtontoexittheapplication
Page4of11
KnowledgeSystemsInstituteGraduateSchoolCIS310IntroductiontoProgramming(VisualBasic) BuildingtheDirectionsApplication
Step1
ControlstobeAdded
Step2
ControlProperties Label o o o Name:lblDirections Text:TravelingonI89,etc Visible:False
Page5of11
KnowledgeSystemsInstituteGraduateSchoolCIS310IntroductiontoProgramming(VisualBasic) BuildingtheDirectionsApplication
Step3
TheCodeWindow Doubleclickingacontrolindesignmode: opensthecodewindow createsacodetemplateforthecontrolseventhandlerwhereyoufillinthecodefortheevent
Step4
TheClickEventHandlerforbtnDisplayDirections
Page6of11
KnowledgeSystemsInstituteGraduateSchoolCIS310IntroductiontoProgramming(VisualBasic) BuildingtheDirectionsApplication
Step5
ChangingaControlsVisiblePropertyinCode Specifythecontrolname(lblDirections) Thenadot ThenthePropertyName(Visible) Forexample: o o o lblDirections.Visible referstotheVisiblepropertyofthelblDirectionscontrol Thevisiblepropertyvaluesmayonlybetrueorfalse
Step6
TheAssignmentStatement Specifytheitemtoreceivethevalue Thentheequalsymbol Thenthevaluetobeassigned Forexample: o o o lblDirections.Visible=True AssignsthevalueTruetotheVisiblepropertyofthelblDirectionscontrol CausesthetextofthelblDirectionscontroltobecomevisibletotheuser
Page7of11
KnowledgeSystemsInstituteGraduateSchoolCIS310IntroductiontoProgramming(VisualBasic) BuildingtheDirectionsApplication
Step7
TheClickEventHandlerforbtnExit
Page8of11
KnowledgeSystemsInstituteGraduateSchoolCIS310IntroductiontoProgramming(VisualBasic) BuildingtheDirectionsApplication
Step8
UseVisualBasictoUpdatetheApplication Placethelabelandthebuttonsontheform Enterthecodeforthetwoprocedures Testtheapplication
Page9of11
KnowledgeSystemsInstituteGraduateSchoolCIS310IntroductiontoProgramming(VisualBasic) BuildingtheDirectionsApplication
ModifytheDirectionsApplicationForFun!
Button o Name:btnDisplayHideDirections
Page10of11
KnowledgeSystemsInstituteGraduateSchoolCIS310IntroductiontoProgramming(VisualBasic) BuildingtheDirectionsApplication
Public Class Form1 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load lblDirections.Visible = False btnDisplayDirections.Enabled = True btnHideDirections.Enabled = False btnDisplayHideDirections.Text = "Display Directions" btnDisplayHideDirections.BackColor = Color.OrangeRed btnDisplayHideDirections.ForeColor = Color.White End Sub Private Sub btnDisplayDirections_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDisplayDirections.Click ' Make the directions visible. lblDirections.Visible = True btnDisplayDirections.Enabled = False btnHideDirections.Enabled = True btnDisplayHideDirections.Text = "Hide Directions" btnDisplayHideDirections.BackColor = Color.Green End Sub Private Sub btnHideDirections_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnHideDirections.Click ' Make the directions invisible. lblDirections.Visible = False btnDisplayDirections.Enabled = True btnHideDirections.Enabled = False btnDisplayHideDirections.Text = "Display Directions" btnDisplayHideDirections.BackColor = Color.OrangeRed End Sub Private Sub btnDisplayHideDirections_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDisplayHideDirections.Click If lblDirections.Visible = False Then lblDirections.Visible = True btnDisplayDirections.Enabled = False btnHideDirections.Enabled = True btnDisplayHideDirections.Text = "Hide Directions" btnDisplayHideDirections.BackColor = Color.Green Else lblDirections.Visible = False btnDisplayDirections.Enabled = True btnHideDirections.Enabled = False btnDisplayHideDirections.Text = "Display Directions" btnDisplayHideDirections.BackColor = Color.OrangeRed End If End Sub Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click ' Close the form. Me.Close() End Sub End Class
Page11of11