Download presentation
Presentation is loading. Please wait.
1
Outline Review Visual Basic.NET Environment Review Visual Basic.NET Environment First Visual Basic Planning and Programming First Visual Basic Planning and Programming Finding and Fixing Errors – Debugging Finding and Fixing Errors – Debugging Summary Summary
2
Using Microsoft Visual Studio.NET
3
Using Microsoft Visual Studio.NET (continue)
4
Naming Rules and Convention Examples: ObjectPrefixExample FormfrmfrmHello ButtonbtnbtnPush TextboxtxttxtName LabellbllblMessage Radio button radradBold Check BoxchkchkPrint
5
A First Program Example Develop a simple program that Develop a simple program that Display a titleDisplay a title Has one Label that display data when a button is pressedHas one Label that display data when a button is pressed Has two ButtonsHas two Buttons Write procedure code for each event Write procedure code for each event Save the form Save the form Save the project Save the project Run the program Run the program
6
Planning: GUI Design Text displayed here Push Me Exit frmHello lblMessage btnPush btnExit Text property ECET/CS 114 Label
7
Planning: Object Properties Form Form Name: frmHelloName: frmHello Text: Hello worldText: Hello world Size: as requiredSize: as required Label at top of form Label at top of form Let VB name this label (default)Let VB name this label (default) Text: “MIS 255” Font: Default, size to fit label boxText: “MIS 255” Font: Default, size to fit label box First Information Label First Information Label Name: lblMessage, Text: Blank, Font: Default, size to fit label boxName: lblMessage, Text: Blank, Font: Default, size to fit label box BASIC code in buttons displays data in labelBASIC code in buttons displays data in label
8
Program Development Example Event Statement Write a VB.NET program that displays the information when a display button is clicked; and exit the program when the exit button is clicked: Press button to display “Hello World”Press button to display “Hello World” Press button to ExitPress button to Exit
9
Define GUI Text displayed here ECET/CS 114 Exit Push Me Labels
10
Define the User Interface - Create a Form Plan the project – one label, two buttonsPlan the project – one label, two buttons Resize the form by drag a corner of the form handle itResize the form by drag a corner of the form handle it Text –Form1 at the Properties windowText –Form1 at the Properties window
11
Define the User Interface (continued) - Place Control on the Form Point to the toolbox icon to open the toolbox on the left sidePoint to the toolbox icon to open the toolbox on the left side Place controls on the formPlace controls on the form Point to A Label and drag, drop on the formPoint to A Label and drag, drop on the form
12
Define the User Interface (continued) - Create Label Drag the mouse pointer to the spot where you want to Drag the mouse pointer to the spot where you want to Pointer to a corner and resize the label on the form Pointer to a corner and resize the label on the form
13
Define the User Interface (continued) - Set Label Properties Click on the label you place on the form Object box Settings box Value in the Settings box
14
Define the User Interface (continued) - Set Label Properties
15
Define the User Interface (continued ) - Label Properties
16
Define the User Interface (continued) - Place Control on the Form Point to Label in the Toolbox and drag, drop on the Form to CreateAnotherlabel
17
Define the User Interface (continued) - Place Control on the Form TextAlignproperty Textproperty Nameproperty
18
Point toPoint to Button in the Toolbox and drag, drop on the Form where you want to Point to a corner and resize the button on the form Point to a corner and resize the button on the form Assign button name: btnPush
19
Define the User Interface (continued) - Place Control on the Form Double click on the button control to create the second button Double click on the button control to create the second button Point to the control and drag the label on the form Point to the control and drag the label on the form Assign button name: btnExit
20
Define the User Interface (continued) - Place Control on the Form Lock Controls -To prevent your form accidentally moving the controls Lock Controls -To prevent your form accidentally moving the controls
21
Define the User Interface (continued) - Set Properties Object box Settings box Value in the Settings box
22
Define the User Interface (continued) - Set Properties for Buttons
23
Define the User Interface (continued) - Set Properties for From1 Double Double click on Form1 Click ClickAnywhere on the Form to Change Properties Properties of the Form
24
Define the User Interface (continued) - Set Properties Change the Text property to “Hello World by Melissa” Change the Text property to “Hello World by Melissa” Hello World by Melissa is displayed at the title of the Form Hello World by Melissa is displayed at the title of the Form Change the Name property to frmHello Change the Name property to frmHello
25
Define the User Interface (continued) - Set File Name In the Solution Explorer, right click on Form.vb In the Solution Explorer, right click on Form.vb Choose Rename from the shortcut menu Choose Rename from the shortcut menu
26
Define the User Interface (continued) - File Name Change the file name from Form1.vb to frmHello.vb
27
Define the User Interface (continued) - Set Startup Object In the Solution Explorer, click on project1, then properties filename Name of the Formclass
28
Define the User Interface (continued) - Set Startup Object In the Project Property dialog box, drop down the list for Startup Object and select frmHello In the Project Property dialog box, drop down the list for Startup Object and select frmHello Click Apply then click OK Click Apply then click OK
29
Comments and the Assignment Statement Comment Comment used to document codeused to document code Syntax exampleSyntax example ' this is a comment Assignment Assignment used to assign a value to a property (or a variable)used to assign a value to a property (or a variable) SyntaxSyntax variable = value ExamplesExamples Pi = 3.14 Pi = 3.14 lblMessage.ForeColor = Color.Red lblMessage.ForeColor = Color.Red lblMessage.BackColor = Color.Yellow lblMessage.BackColor = Color.Yellow lblMessage.Text = "WebCT is a pretty good tool." lblMessage.Text = "WebCT is a pretty good tool."
30
Write Code Develop a Visual Basic code in Procedures Develop a Visual Basic code in Procedures A sub procedure begins with Private Sub and ends with End Sub A sub procedure begins with Private Sub and ends with End Sub The Remark statement The Remark statement CommentsComments The Assignment Statement The Assignment Statement Assigns a value to a property or variableAssigns a value to a property or variable Ex: btnHello.Hide()Ex: btnHello.Hide() lblMessage.Show() lblMessage.Show() Me.Close() Me.Close()
31
Write Code (continue) A Space then an Underline enables you to press the enter key and continue a line of code on a new line. Each method is defined as a VB procedure Each method is defined as a VB procedure For methods which correspond to events, VB automatically names the procedure For methods which correspond to events, VB automatically names the procedure Private Sub btnPush_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles btnPush.Click End Sub
32
Write Code (continued) Click on Push Me button
33
Write Code (continued) Method List Assignment Statement Remark Statement Editor tab Form Designer tab Class List
34
Write Code (continued) Click on Exit button
35
Write Code (continued) Edit one line of Comment and one line of Code Class List Method List
36
Write Code (continued)
37
Save the Project Open the File menuOpen the File menu Choose Save AllChoose Save All
38
Compiler the project Click on Build, then Select Build Solution
39
Clean Compile & Build
40
Run the Project Open the Debug menu Open the Debug menu Select Start without debugging Select Start without debugging
41
Result of the Project When Click on Push Me button – display Hello WorldWhen Click on Push Me button – display Hello World When Click on Exit button – Close the windowWhen Click on Exit button – Close the window
42
Code View Help The VB Environment
43
Summary Program Planning and GUI Program Planning and GUI Visual Basic Programming Visual Basic Programming Use ToolboxUse Toolbox Edit propertiesEdit properties Write codeWrite code Run the projectRun the project
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.