E N D
Visual Basic Project Files:.VBP file: Project File: a small text file that contains the names of other files in the project, as well as some information about the VB environment(release 2.0 and 3.0 of VB, .MAK extensions for project files).FRM file: Form File: each form in the project is saved in a .FRM extension. Each form file holds a description of all Objects and their Properties for the form, as well as the Basic Code written(In VB each of these Form Files is referred to as a Form Module)
.BAS file: Standard Code Modules: hold VB ‘Basic’ statements that can be accessed from any Form.BAS files are used in multiform projects.OCX file: Custom Controls: additional controls/custom controls are stored in .OCX files. If projects include controls that are not part of the Standard Control Set, then .OCX file names will be included in the project(All controls have .OCX extensions, however, this is implicit in controls internal to the VB Environment, and these extensions are not visible to the user).VBW file: after the project is saved, VB automatically adds one more file to the project, which holds information about each of the project Forms
Project TipCreate a New Folder for a project, before creating any files for the projectSave the .VBP file Save the .FRM files, and Save the .BAS files into the folderThen if the project needs to be copied or transferred from the ‘C: Drive’ to the ‘A: Drive’, all of the project files can be transferred together within the folder, and no component parts (.VBP, .FRM, .OCX[if existing])of the project will be lost Component parts of a project can be lost and always save each component part separately
The VB EnvironmentVB Environment, where projects are createdThe various windows, in the VB Environment, can be moved, resized, opened, and closedThe windows within a project can be customised
MENU BAR TOOLBAR FORM LOCATION & SIZE INFORMATION PROJECT EXPLORER WINDOW FORM1: NAME OF THE OBJECT FORM FORM: CLASS OF THE OBJECT PROPERTIES WINDOW PROPERTIES HELP PANE TOOLBOX FORM LAYOUT WINDOW FORM WINDOW
TOOLBOX POINTER (NOT A CONTROL) PICTUREBOX LABEL TEXTBOX FRAME COMMAND BUTTON CHECKBOX OPTIONBUTTON COMBOBOX LISTBOX HSCROLLBAR VSCROLLBAR TIMER DRIVELISTBOX DIRLISTBOX FILELISTBOX SHAPE LINE IMAGE DATACONTROL OLE
The Form Window is where the forms are designed that make up the User-InterfaceAlways create a ‘User-Friendly’ User-InterfaceStandard windows techniques can be used to change the size and location of the form‘Mouse-Driven Environment’By default, a new form created in a new project, is called Form1, when the file is saved, the programmer assigns a more meaningful name to the file(?: What is the extension?)
The Project Explorer Window holds the filenames of the files included in the projectThe windows Title Bar holds the name of the project, which is Project1 by default, until saved and given a more meaningful name(?: What is the extension?)
The Properties Window, its use relates to setting the properties for the objects in the projectCheck Box 1/0, True/FalseOption Box 1/0, True/FalseCommand Button‘Name’ how the computer recognises/identifies the control/object‘Caption’ relates to the user identification of the control/object Text Box ‘Text’ property: ‘Blank’‘Name’ property: like command buttonForm Window State ‘Maximise’, relates to maximising the form when the project is executed
The Form Layout Window, this indicates the position of the form on the desktop, when the execution of the project beginsThe Toolbox holds the tools that are used to place controls on the formThe tools displayed on the toolbox, may be different, depending on the edition and release of VB being used‘Professional Edition’
The Main Visual Basic Window holds the VB menu bar, the toolbar, and the form location and size informationThe Toolbar, the buttons on the toolbar can be used as shortcuts for frequently used operationsEach button represents a command that can be executed by clicking on the button or by choosing a command from the menu barThe Form Location and Size Information identifies the size and position of the form on the screen
Help VB has an extensive ‘Help’ facilityVB contains what is called ‘Context-Sensitive’ help
Design Time, Run Time,Break TimeVB has 3 distinct modes:Design Time: relates to designing the ‘User-Interface’ and writing codeRun Time: relates to testing and running the projectBreak Time: if there is a ‘run-time error’ or project execution is paused
VB Project ExampleThe first ‘Event-Driven’ project will create a form with 3 controlsIt will display the message ‘Hello world’ when the user clicks the ‘Push Me’ command button, and will terminate when the user clicks the ‘Exit’ command button(Tip: If the Project Explorer Window/Properties Window/Toolbox are not displayed, open the View menu and select Project Explorer Window/Properties Window/ Toolbox
Project Tips Do not confuse the ‘Name’ and ‘Caption’ properties‘Name’ refers to the control in the VB code‘Caption’ refers to the users view on the formVB sets both of these properties to the same value by default, and therefore it is easy to confuse themNB: Always set the ‘Name’ property of controls before writing codeIf the ‘Name’ of an object is changed after the code has been written, then the code becomes separated from the object and the program does not run properly
When a VB project is running, the user can do many thingsEach action by the user causes an ‘Event’ to occur in the VB projectIf you write VB code for a particular event, the VB will respond to the event and automatically execute your procedure (eg: clicking on a command button)VB ignores events for which no procedures are written(eg: moving the mouseresizing a windowopening another application)
VB code written in proceduresWe deal with writing code in ‘Sub Procedures’ or ‘Sub Programs’Begins with: Private SubEnds with: End Sub
VB automatically names the event proceudresThe ‘Name’ consists of the object name, an underscore ( _ ), and the name of the event(name of the command button is cmdPush and there is a Click event for the command buttonTherefore, the name of the Sub Procedure:cmdPush_Click