Report

Visual Basic - Beginning

To view this page ensure that Adobe Flash Player version 9.0.124 or greater is installed.

Get Adobe Flash player
Please login or register to make a comment!

Instructor 9s Notes Visual Basic - Beginning Intro to Program Development Intro to Program Development--1 Visual Basic - Beginning Intro to Visual Studio 2005 Notes Activity Text References " Programs Pages 4 3 6 " Microsoft Visual Studio 2005 Pages 20 3 26 " Solutions, Projects and Source files Pages 53-54 " Starting a new Project Pages 42 3 52 " IDE Pages 26 3 32 " Controls Pages 9 3 13, 47 " 100 3 101 " Forms Pages 42 3 43 " Labels Pages 44 3 47 76 3 77 " PictureBoxes Pages 48 3 50 " Buttons Pages 64 3 65 " Code Window Pages 66 3 68 " Help System Pages 80 3 86 Read Chapter 2 Creating Computer Programs " To create your own programs for a computer, you need a programming language. There are dozens (hundreds?) of programming languages, including COBOL, RPG, Visual Basic, Java, C++ and C#. " You use the algorithm/pseudocode you developed in the design phase to convert your logic into the programming language statements.

- Computers can not understand these statements, they only understand 0 9s and 1 9s. - The compiler converts the programming language statements into machine language. - ... more. less.

The compiler also informs you if you have broken any of the rules of the language.<br><br> " Today, most compilers come packaged with other tools - editors to key in your statements - debuggers to help locate errors in your program Instructor 9s Notes Visual Basic - Beginning Intro to Program Development Intro to Program Development--2 Notes Activity Procedural versus Object-Oriented Programming Procedural Programming Languages: " Break the logic down into major tasks called procedures. " Program determines and controls the order the computer processes the tasks " Examples: COBOL, RPG, Procedural C++ Object-Oriented Programming Languages: " Focus is on the objects the program can use to accomplish its goal/task. " Objects are treated as independent units.<br><br> " Objects can be used in more than one program with little change. " Many predefined objects available Objects An object is anything you can see, touch or use 3 a thing. " Common objects: label, button, checkbox, menu " Other objects: can represent something in real life 3 person, employee, building and a purchase order.<br><br> All objects have: " Attributes/properties 3 characteristics that describe them " Behaviors 3 methods and events - Methods 3 action the object can perform - Events 3 action that the object responds to such as clicking a button or when a textbox control changes. Objects are created from classes. A class is: " Pattern or blueprint used to create an object.<br><br> " All objects of the same class have the same properties and behaviors of that class. Instructor 9s Notes Visual Basic - Beginning Intro to Program Development Intro to Program Development--3 Notes Activity About Microsoft Visual Studio 2005 In this class (and Programming Logic - Intermediate), we 9ll be using Microsoft Visual Basic 2005 (which is part of the Visual Studio software). This software comes with an editor, a compiler, a debugger and a help system to help you learn the language.<br><br> These components together are called the integrated development environment (IDE). Visual Basic 2005 runs in Microsoft .NET Framework 2.0. .NET framework is " Platform on which applications are created " Goal is to connect information, people, systems and devices.<br><br> " Supports VB, C++, C# (C sharp) and J#. " Contains the common IDE " Contains common set of classes shared by the above languages: - Prewritten code for Windows components (form, toolbars, textboxes, etc). - Common utilities 3 math utilities, string manipulation.<br><br> " .NET Framework must be installed on computers that run/use Visual Studio languages. Instructor 9s Notes Visual Basic - Beginning Intro to Program Development Intro to Program Development--4 Notes Activity Solutions, Projects and Source Files " Visual Studio NET includes the opportunity to combine many projects into a solution . - Solutions are containers that can hold many projects.<br><br> - Each project could be written in a different language - Used for large, multi-person system development - For our purposes, solutions will only have one project (but that one project must still be included in a solution ) - File extension for the solution is . sln " All the source files for one program are combined into a project - All project files are written in the same language. - Projects must belong to a solution.<br><br> - The project folder is created and stored in the Solution folder. - File extension for the project is .vbproj . The project will be stored in a folder with the same name as the solution.<br><br> - Other files are created in the project folder as well. " VB.NET programs include many source files . - Code required to create forms and manipulate the objects on those forms - Utility code used by more than one form or more than one program.<br><br> - File extension for the Visual Basic source files is .vb " All source files are combined to form a project which is part of a solution (always). Instructor 9s Notes Visual Basic - Beginning Intro to Program Development Intro to Program Development--5 Notes Activity Starting Microsoft Visual Studio 2005 To start the process of developing your own program, you 9ll first have to start Microsoft Visual Studio 2005 1. Open the Start Menu, select and click Microsoft Visual Studio 2005.<br><br> " Note: there will be slight differences if you are using Visual Studio 2005 Express versus Visual Studio 2005. 2. Once you have the application running, you will see a tabbed window - Start Page .<br><br> The screen will vary from the book and from the first time and consecutive times you enter the IDE. " If you do not have the Start Page, click View menu option, click Other Windows and then click Start Page . Start Visual Basic 2005 Instructor 9s Notes Visual Basic - Beginning Intro to Program Development Intro to Program Development--6 Notes Activity Customizing the Visual Studio IDE " Tools 4 Options on the menu " Option Strict - Projects and Solutions 4 VB Defaults - Forces VB to use strict syntax rules - Turn on - Discussed later " Default Solution Folder - Projects and Solutions 4 General - Designates the where solutions and folders are stored by default - Suggest H: drive or Desktop.<br><br> - Pen drives may reduce performance. Work on Desktop, copy to pen when done " Save New Project - Projects and Solutions 4 General - By default, VS doesn 9t save new projects until you run or save manually. Doesn 9t even create the folder - Check Save new projects when created " Tab Settings - Text Editor 4 Basic 4 Tabs - By default, VB indents code 4 spaces.<br><br> Three (3) saves space. - Leave Smart Indenting on " Remove Start Page - Environment - Show all settings - Startup - Change At startup: - Constantly closing Start Page gets to be a pain - Suggest Show empty environment - If launch project from My Computer, that project will be loaded - If launch Visual Studio, can still open projects from the File menu - If want to see Start Page use the menu View 4 Other Windows 4 Start Page " Setting stick even after you close Visual Studio - Will need to set these on all computers you use. Instructor 9s Notes Visual Basic - Beginning Intro to Program Development Intro to Program Development--7 Notes Activity Starting a New Project Each application you create within Visual Studio is called a project .<br><br> We are now ready to start a new project. 1. Under Recent Projects , click on Project& next to Create .<br><br> 2. In the Project Types pane on the left, ensure Visual Basic is selected . 3.<br><br> In the Template pane, select Windows Application. 4. In the Name textbox, you will enter the name of your project.<br><br> Do not keep the default of WindowsApplication1. 5. Change the Name to something meaningful to describe the project.<br><br> (Note: follow standards/guidelines identified by the instructor). 6. You can close the Start window if you want by clicking the X when the Start tab is selected.<br><br> Be careful not to close the entire IDE. Create a new project called Sample Show Solution, Project and files generated Instructor 9s Notes Visual Basic - Beginning Intro to Program Development Intro to Program Development--8 Notes Activity Common Windows and features in the IDE The IDE contains 5 common windows: " Start page 3 create and open projects, access information on how to use Visual Studio 2005, latest news and technical articles. " Solution Explorer 3 displays the names of projects and files included in this solution (application).<br><br> Appears on the top right portion of the IDE. - Shows all the projects in the solution (only 1 for our purposes) and the source files included in the projects - Windows Form files are designated with this icon - Code files are designated with this icon - Using the Solution Explorer Toolbar (from left to right) 2 Properties: makes the properties window active 2 Show All Files: shows the files generated by Visual Studio. (We will use this in the next unit) 2 Refresh: Refreshes the current project 2 View Code: displays the Code window 2 View Designer: displays the Design Window for that active form " Toolbox 3 displays objects/controls you can use/add when creating a project.<br><br> The toolbox tab appears on the left side of the screen. " Properties 3 displays properties associated with the active object/control of the form. " Database Explorer 3 displays data connections and servers (will be used in Programming Logic Intermediate) Other features: " Menu 3 provides access to activities you can do within the IDE.<br><br> " Toolbar 3 buttons under the menu; can be moved, hidden, displayed and customized. Locate each Window In Solution Explorer: Select the Show All files and View Code/View Designer Instructor 9s Notes Visual Basic - Beginning Intro to Program Development Intro to Program Development--9 Notes Activity Saving the project Save your work often to prevent loss of changes. You can save the project by: " Option 1: Select Save All from File menu.<br><br> - The Location textbox shows where the project folder will be created. You can change this by clicking Browse button and select the drive/folder location. - The Solution Name will be the folder the project will be stored in.<br><br> Keep the Solution and project names the same. - Then click OK. " Option 2: Press Ctrl-Shift-S on keyboard and follow above steps for location and Solution name.<br><br> " Option 3: Click Save All button on the toolbar. " Option 4: Run the program. By default Visual Studio saves all the project files before running the program.<br><br> Save Sample Closing the project If you did not do a Save All , you will be prompted to Save the solution. In the Save Project dialog box, complete the following. 1.<br><br> The Location textbox shows where the project folder will be created. You can change this by clicking Browse button and select the drive/folder location. 2.<br><br> The Solution Name will be the folder the project will be stored in. Keep the Solution and project names the same. Then click OK.<br><br> If you saved the project earlier but made changes, you will be prompted to save the project. Close Sample Opening Existing Projects You can open an existing project in (at least) 4 ways: 1. Locate the .sln file using Windows Explorer (My Computer) and double-click it 2.<br><br> Open Microsoft Visual Studio 2005. While on the Start Page, select the project listed in the Recent Projects list. The project will open (unless it was moved to a different location).<br><br> 3. Click Open Project& option and locate the project in the Open Project dialog box. Select the solution file (.sln) and click Open.<br><br> 4. Click File in the menu, click Open Project in the file menu and browse for the project using the Open Project dialog box. Select the solution file and click Open.<br><br> Open Sample Instructor 9s Notes Visual Basic - Beginning Intro to Program Development Intro to Program Development--10 Notes Activity Managing the IDE As mentioned above, there are five common windows open in the IDE. More windows can be open depending on what activity you are doing. " To close an open window, click the Close button " To open a window, use the View menu " To auto-hide a window, click the Auto Hide button (looks like a push pin) " To display an auto-hidden window, place the mouse pointer on the window 9s tab.<br><br> " To permanently display an auto-hide window, click the Auto Hide push pin. " Typically, do not hide the Solution Explorer and Properties windows. Hide the Toolbox after you have developed the form because you will not need this window out as much.<br><br> " Resize a window - Move cursor to the edge of the window and the sizing pointer appears for you to drag the window to the needed size. - You can the Properties window (and other windows) longer by placing the cursor at the top of the window and dragging the title up. This makes it easier to work with changing the objects properties.<br><br> Practice closing, opening and auto hiding windows Windows Form Designer Window You create/design the GUI for the project using the Windows Form Designer. " The form object is the foundation/container for the user interface in Windows applications. " Add objects (controls) from the ToolBox (such as labels, buttons and textboxes) to the form.<br><br> The form is an object itself. " If the form is not displaying, double click on the Form1.vb (or associated name) in the Solution Explorer to display the designer view. All objects have properties that describe the object.<br><br> As you design your application, you can change the properties using the Properties Window. The properties can be ordered alphabetically or by category. Display the properties of the form in alphabetical and then category order Instructor 9s Notes Visual Basic - Beginning Intro to Program Development Intro to Program Development--11 Notes Activity Changing Source File Name A source file is a file that contains program instructions or code .<br><br> The Form1.vb source file is known as the form file . " Contains the code associated with the Windows form object or form . " Change the default name of the source file from Form1.vb to something more meaningful .<br><br> There are two ways possible: - Click on Form1.vb in the Solution Explorer to get focus. Click again to be put in edit mode to rename the form. - Click on the Form1.vb to get focus.<br><br> In the properties window, change the Name property. - REMEMBER: include the . vb extension.<br><br> - DO NOT change the solution, project or source file names directly from Windows. Use the IDE to change the names. The appropriate directories in the application will not get updated if you do not go through the IDE.<br><br> - Use meaningful names that describe the purpose of the form. (Ex: WelcomeScreen, EmployeeEntry, UpdateScreen) Change the name to frmSample.vb Naming Objects Objects that are referenced in code or by an event , will need to be named. If the object requires an event procedure or the properties of the object are changed in code 3 rename the object from the default value.<br><br> 1. Click on the object to select it 2. In the properties window, change the (Name) property.<br><br> 3. Enter a descriptive name for the object " Our programming standards dictate all object names should begin with a prefix. " The name begins with the 3 character prefix in lower case followed by descriptive name to identify the control.<br><br> The first letter of each word of this name is capitalized. " Examples: frmSample, lblName, txtAddress, btnExit, picLogo " Refer to the class standard prefixes for a complete list. Note: If an object is NOT referenced in code or by an event, you can keep the default name.<br><br> Rename the form to frmSample Instructor 9s Notes Visual Basic - Beginning Intro to Program Development Intro to Program Development--12 Notes Activity Form Properties " Text 3 changes what appears on the form 9s title bar " BackColor 3 changes the background color of the form Note: when form 9s background color is changed, the background color of all objects on the form whose background color was not set will adapt the background color of the form. " Icon 3 set the icon that appears in the form 9s title bar " StartPosition - where the form appears on the screen (normally 3 CenterScreen) " Font 3 set the font (type, size, etc) for all objects on the form (unless those objects properties are set) " ForeColor - set the font color for all objects on the form " BackgroundImage Select an image to display on the form 9s background. Use the backgroundImageLayout for desired look.<br><br> Note: your project now has a folder called Resources into which the source image has been copied. Changing Properties of Controls As a control is introduced in the notes, the common properties that are changed for that control are presented. Note: if you change properties and want to reset them back to the original value, just right- click on the property and select Reset .<br><br> Change these properties on the Sample form Text 3 Class Sample BackColor 3 select a color of choice Icons: select an icon from the class folder BackgroundImage: select from class folder Complete Checkpoint pg 57 Instructor 9s Notes Visual Basic - Beginning Intro to Program Development Intro to Program Development--13 Notes Activity Adding Controls The toolbox contains the standard tools to add to forms. In OOP terms, the tools represent a class. When you add an object to the form, we call them controls .<br><br> There are 4 ways to add a control 3 " Option 1: - Double-click a tool in the toolbox " Option 2: - Click a tool in the toolbox and drag the pointer to the form. - Release the mouse button when the pointer is on the form. " Option 3: - Click the tool and then click the form " Option 4: - Click the tool, then press the mouse pointer on the form and press the left mouse button to drag the pointer until the control is the desired size Add 3 labels 3 using each of the 3 methods mentioned Manipulating Controls Once the control is on the form, it can be moved, deleted, sized, select multiple controls and aligned multiple controls.<br><br> " Moving Controls - Place mouse over object - When the pointer changes to a four-headed arrow (move arrow to get it to change), click and drag the object to the new location. " Deleting Controls - Click on the control to gain focus and hit the delete button - Or, click on the control and select the Cut toolbutton. Move labels Delete a label Add the label again Change the size of each label Select all 3 labels 3 try each option Instructor 9s Notes Visual Basic - Beginning Intro to Program Development Intro to Program Development--14 Notes Activity " Sizing Controls - Click on the control to select it.<br><br> - Place the mouse over one of object sizing handles (the small white squares around the middle of each edge of the object). Note: Small handles on the corners are used to adjust both height and width - Drag handles to resize the object. " Select Multiple Controls - Option 1: Click on the first control, then Ctrl-Click or Shift- Click additional objects to select them.<br><br> Ctrl or Shift-Click the object again to deselect it. NOTE: the first object selected controls the alignment (has white handles) - Option 2: Point to an empty area near the first object Drag a box that encompasses all the objects you want selected. Best used when objects are near each other - Option 3: Press Ctrl-A to select all objects on a form " Aligning Controls - When you drag a control to a position on the form, a blue guide/grid line automatically appears when the controls are aligned.<br><br> - Guide line only appears when controls are in line. - Guide can be used to align vertically and horizontally. - Option 2: Select controls you want to align Click on Format menu option, select Align and select desired alignment - Option 3: With the Layout toolbar showing (to display 3 select View / Toolbar / Layout Click on toolbar for the type of alignment desired.<br><br> Move labels as a group Deselect labels Move labels so they are not aligned Now 3 align labels using the grid Complete Checkpoint pg 53 Instructor 9s Notes Visual Basic - Beginning Intro to Program Development Intro to Program Development--15 Notes Activity Labels Labels are used to: describe other objects on the form ( what should be entered in this text box? ) and display information to the user (such as output results or directions/remarks that don 9t change) " Add a label object to the form (see above) " Labels used to describe other objects or display information that does not change 3 ARE NOT renamed (default name used) because code rarely refers to them. " Labels used to display results will be used in code and should have a descriptive name ( lbl prefix).<br><br> Properties: " AutoSize property of a label is set to True by default. Makes the label adjust to the size of the Text property contents. Gives the control a dotted-line rectangle called bounding box.<br><br> This marks the tightest rectangle that contains all of the control and you can not manually change the size of the label. To change the size, set the AutoSize to False " Text - controls the words that appear on the label " Image - to add a picture to the label " ImageAlign - control where on the label the image appears " TextAlign - control how the text aligns on the label (often in relation to an image location) Add a title to the form and set it's text properties ( This program was written by:) Note: same color as form background Change: Font Add another label and put you 9re name in the text. Place under the title label " Font - change the appearance of the label's text: font, style and size.<br><br> " ForeColor - change the color of the text on the label " BackColor - change the color of the label itself Labels are often transparent so the form's background shows through. Note: If a background Image was put on the form, the label takes on the background color and is not transparent. " BorderStyle - set the kind of border the label has around it.<br><br> Labels describing another control don't have a border Labels displaying output - set to FixedSingle " Visible - indicates if label can be seen on the form Note : many objects have the same properties (Font, BackColor, Left, Top, etc). After having been described once in the these notes, they will not be described again. Add another label with the course name by copying the first label.<br><br> Add MSTC Logo.gif as label image. Experiment with alignment Add a border to this label Instructor 9s Notes Visual Basic - Beginning Intro to Program Development Intro to Program Development--16 Notes Activity " T I P - If you need many objects that have the same appearance (e.g. many labels with the same font size) Create one object and set it properties appropriately Copy the object to the clipboard Paste a copy of the object onto the form and position it appropriately Don't forget to rename the copy - Alternatively, after you 9ve finished formatting one object, press the Ctrl key, point to the object and drag it to a new location 2 A small plus sign should appear next the mouse pointer to designate you 9re adding (copying) a control 2 The new control will have the same format as the original but will be assigned a default name.<br><br> - You can also place the objects on the form, select them all and change the properties for all of them at once. Experiment with getting the Font properties for the labels with text to be the same. Try doing thiw with both controls selected.<br><br> PictureBox Pictures improve the appearance of the form when used appropriately. NOTE: The form itself can have a background image but it can not be resized or repositioned. " Add a PictureBox to the form Properties: - Name - use pic prefix - Image - designate which image should be displayed You can use animated GIFs in picture boxes.<br><br> If you want to stop the animation, set Enabled to False - SizeMode Normal: Picture is aligned top-left, as much of the image as possible displays CenterImage: the image centers itself in the box, as much of the image as possible displays AutoSize: the size of the PictureBox adjusts to accommodate the entire image StretchImage: the image will distort to completely fill the PictureBox " Size and position as necessary " Commonly modified properties: Left , Top , Height , Width , BackColor , BorderStyle Add a PictureBox to the form Set the SizeMode to StretchImage Assign the bookImage to the form Size the PictureBox to increase the image size Experiment with size mode Experiment with the visible property Instructor 9s Notes Visual Basic - Beginning Intro to Program Development Intro to Program Development--17 Notes Activity Buttons Buttons allow users to designate when program actions should take place " Add a button to the form Properties: - Name - use btn prefix - Text - change the words that appear on the button " Size and position as necessary " Commonly modified properties: Left , Top , Height , Width , Font , ForeColor , BackColor , Image , ImageAlign , TextAlign Add an OK button to the form with the Exit icon and the text OK Experiment with text alignment Code Window Everything you create using VB.NET generates code. " A lot of code is generated automatically by VB.NET - Code to create a form - Code for every object placed on the form " To view the code for a form, double-click on any object on the form or on the form itself. " The event most applicable to the object you double-clicked will be shown.<br><br> The code template consists of the Sub procedure header line and the End (last) line. Double-click the form object to open the code window Instructor 9s Notes Visual Basic - Beginning Intro to Program Development Intro to Program Development--18 Notes Activity " Code Features - Works a lot like a word processor Cut, copy and paste Drag to move or copy (Ctrl-drag) - Color coding to make code more readable Reserved words in blue Comments in green - Auto-indent VB.NET uses the indentation of the previous line to set the indentation of a new line Press Tab to indent further, back space to move to the previous indent - Auto-End VB.NET automatically inserts End statements for decision and loop constructs (appropriately indented) - Auto-List Members Whenever you refer to an object or a class, VB.NET shows you the members and methods of that class as soon as you press a period (.) Select the value using the Tab or Spacebar - Error Highlighting Just like when you make a spelling error in MS Word, VB.NET highlights syntax errors (language errors) by underlining the erroneous code with a blue wavy line . - Unused variable highlighting (discussed later) Green wavy line Enter sample code to change the form's background color.<br><br> Me.backcolor (Note auto member list) (Note color coding) Me.backcolor = Color.red (Note auto member list) Press enter (Note auto indent) Adding Code to a Control Objects know how to handle events , things that users do to the object. " The most common type of event is the Click event that occurs when a user clicks an object " To keep our first application simple, we are going to add some simple code to our button's Click event " To add code to an object 9s event handler, simply double-click the object - The code editor will open in a new tab and VB.NET will create a procedure (a small section of code) header for the most commonly accessed event for this object (often the Click event). - Type the appropriate VB.NET statements/commands for this event.<br><br> Double-click on the btnOK Add Me.Close with a comment Instructor 9s Notes Visual Basic - Beginning Intro to Program Development Intro to Program Development--19 Notes Activity Switching Views You will be switching from the Code Editor to the Form Designer often. " Simply click the appropriate tab at the top of the design window ( [Design] designates form design) " If you're in form design, it's often more convenient to simply double-click an object to get to the Code Editor " You can also use the Solution Explorer window. Click the View Designer button to switch to the Design window.<br><br> Click the View Code button to switch to the Code window. Try it Syntax Rules Syntax or language syntax, defines the correct way to use a specific programming language. Syntax errors occur when you don 9t follow the rules 3 Visual Basic can 9t understand the command you 9re trying to give.<br><br> If a programmer violates Visual Basic syntax, the application will not run until it is corrected. Most syntax errors are typing errors. A nice feature of Visual Studio is it checks for syntax errors as you are writing your code.<br><br> When you move to the next line of code, the previous line is checked. If there is an error, a blue wavy line appears under the part of the statement that is in error. " Position your mouse on the blue squiggly line and an error message appears.<br><br> " Fix the error and click off the line to verify the code is correct. If you do not fix the error and try to run the application, you will not be able to run the application until the errors are fixed. (Refer to the Testing/Running section below) If you do not have syntax errors but your program does not work as designed, you have logic errors .<br><br> You need to review the code to verify you entered the statements correctly. In the frmSample_Load event, key in Backcolor And hit enter Notice the blue squiggly line. Put cursor on blue line to see error Instructor 9s Notes Visual Basic - Beginning Intro to Program Development Intro to Program Development--20 Notes Activity Testing / Running a Program During the project development process, you will want to test your program to make sure it is working as planned.<br><br> During the testing process, the code you wrote is compiled to make sure the statements follow the rules of the language called syntax rules. Syntax or language syntax, defines the correct way to use specific programming language. Syntax errors occur when you don 9t follow the rules 3 Visual Basic can 9t understand the command you 9re trying to give.<br><br> If a programmer violates Visual Basic syntax, the application will not run until it is corrected. Most syntax errors are typing errors. If you do not have syntax errors but your program does not work as designed, you have logic errors .<br><br> You need to review the code to verify you entered the statements correctly. To test and run a VB application: " Click the Start Debugging button on the toolbar or press the F5 key " If there are remaining errors in your code (referred to as Build Errors by VB.NET), VB.NET will let you know and you'll have to fix them before you can run the program. - An Error List window will display to identify the errors.<br><br> - Double click on an error and you will be taken to the appropriate line of code. - Evaluate the code and correct the error " To stop a running program - close its window by clicking the X in the upper right corner OR - click the Stop button on the Debug toolbar If the Debug toolbar is not visible, right-click any toolbar and select it from the popup menu - If the Immediate Window remains visible, close it Click the Start debugging button Click the Stop debugging button Change the code in the form load to be: BackColor = red This will cause a blue squiggly line Click the start debugging 3 you will get a message box indicating there are errors. Answer no to see the Error list window.<br><br> Fix errors Run the program and then Close it. Instructor 9s Notes Visual Basic - Beginning Intro to Program Development Intro to Program Development--21 Notes Activity Adding Comments to Code Comments are descriptions of the project as a whole or code in the project, added by the programmer, to further describe what the code does. " To add a comment in VB.NET, type an apostrophe ( ' ) followed by the descriptive comment " The apostrophe can appear anywhere in a line of code (beginning or middle) but all text after the apostrophe is ignored.<br><br> " The comments will appear in green Types of Program Documentation " Application level 3 describes the Name of the project, programmer name, date, purpose and any changes made to the application. - For now, enter the general program documentation in the code for the main form . - Enter the comments after the Public Class statement - Use the following general program documentation for all projects in this course: Project Name: Sample.vb Programmer Name: Programming Logic Student Date: Month day, year Purpose: Provide a short explanation of the project 9s purpose.<br><br> You must use complete sentences. Change Log: Date of change1 3 description of change 1 Date of change2 3 description of change 2 " Form-level - form level documentation identifies the procedures (for now 3 just events) within the form and the purpose of the procedure. " Variables and Constants level 3 for each variable and constant (described in next unit), provide a purpose for the variable/constant using inline comments.<br><br> " Code level 3 for more complex blocks of code, provide internal documentation describing what the logic does. Complete Checkpoint pg 70 and pg 73 Instructor 9s Notes Visual Basic - Beginning Intro to Program Development Intro to Program Development--22 Notes Activity Regions Directive You have the ability to group your code into regions. This features will collapse and expand code within the region.<br><br> " Begin with # Region c identifier-name d " Ends with # End Region #Region "DataValidation" ' Insert code for the Data validation logic here. #End Region " Consider using regions to contain your application and form documentation The Final Touch Hopefully, when you created and customized your form, you assigned an icon to the form. This icon appears in the form 9s title bar and in the Windwos toolbar when the form is active.<br><br> However, there is one more place you need to define an icon 4the project itself. The project icon displays on the executable file of your program. Each of the project 9s forms and the project itself can have unique icons.<br><br> Note: You 9ll find your program 9s executable file in the Bin, Debug folder of your project folder. To add a project icon: " Locate the icon you 9d like to use for your project using Windows or an external icon management program. o There are lots of icons on the I: drive " Copy the icon to your solution folder " Double-click My Project in the Solution Explorer " Drop down the Icon: list.<br><br> " Choose the Browse option " Locate your icon " The icon should appear in the My Project window Instructor 9s Notes Visual Basic - Beginning Intro to Program Development Intro to Program Development--23 Notes Activity Object Oriented terms This section introduces you to object-oriented terms you will read or hear about. " Class - a patter or blueprint used to create an object. - Every object used in an object-oriented program comes from a class.<br><br> " Instance 3 objects created from a class are referred to as an instance of the class and said to be cinstantiated d from the class. - You can have multiple instances of an objects from the same class in your application. (Ex: you can have 3 labels on your form, you can have 2 buttons on your form).<br><br> - Each object is uniquely referenced by its name. " Encapsulation 3 hiding all the properties (data) and behaviors (methods and events of an object) in one package. By doing this the programmer can use the class without having to know exactly how the class is coded.<br><br> This is known as information hiding. (Example: you can drive a car without having to know how the engine, brakes and exhaust work internally) " Inheritance 3 you can create one class from another class. The new class inherits the attributes and behaviors of the original class.<br><br> " Polymorphism - an object-oriented feature that allows the same instructions to be carried out differently depending on the object and the situation. For example: you can open a door but you can also open your eyes, open a jar or open a box. Instructor 9s Notes Visual Basic - Beginning Intro to Program Development Intro to Program Development--24 Notes Activity Help System " The Visual Studio Help System is a valuable tool.<br><br> Learn to use it!! " Dynamic Help is only available in Visual Studio 2005. - To display Dynamic Help, select Help menu, then Dynamic Help .<br><br> - A new window is displayed providing the following Help tools 2 How Do I & 2 Search 2 Index 2 Contents " If you are using Visual Basic Express, you access the Help system through the Help menu and then select from the above Help tools (listed above). - The Help system is displayed in a separate Window so you can move between your application and the Help information. Complete Using Visual Basic Help 3 Tutorial 2-17 (Note: Visual Basic Express may differ slightly from Visual Studio) Complete Checkpoint pg 87<br><br>

less

Copyright © 2010 beepdf.com. All rights reserved.