Slide 1:VISUAL BASIC INTEGRATED DEVELOPMENT ENVIRONMENT
Slide 2:The IDE is:
where you do your programming work in Visual Basic.
you develop your projects in the Integrated Development Environment.
used to be more or less invisible to the programmer.
Now there are all kinds of project options, ActiveX controls to add, version resource data to set, and so much more.
Slide 3:The Visual Basic IDE has three distinct states:
Design
Run
Debug.
Design: this states appears in the visual basic title bar and forms the main part of the integrated development environment
Run : In the Run state, Visual Basic is in the background while your program runs.
Debug: this is the state where you get the environment to debug your applications and fix the errors.
Slide 4:COMPOSITION OF IDE
The menu bar
The toolbar
The Project Explorer
The Properties window
The Form Layout window
The toolbox
Form designers
Code windows
Slide 5:Project explorer Properties window Form layout window toolbox Form designer Code window toolbar Menu bar
Slide 6:The Menu Bar
File: File handling and printing; also used to make EXE files
Edit: Standard editing functions, undo, searches
View: Displays or hides windows and toolbars
Project: Sets project properties, adds/removes forms and modules, and
adds/removes references and components
Format: Aligns or sizes controls
Debug: Starts/stops debugging and stepping through programs
Run: Starts a program, or compiles and starts it
Tools: Adds procedures, starts the Menu Editor, sets IDE options
Add-Ins: Add-in manager, lists add-ins like Application Wizard and API Viewer
Window: Arranges or selects open windows
Help: Handles Help and the About box
Slide 7:The Toolbar
This toolbar contains buttons matching popular menu items
Clicking the button is the same as selecting a menu item and can save you some time.
Besides the main toolbar, you can also display other dockable toolbars in Visual
Basic: the Debug, Edit, and Form Editor toolbars.
To display one of these toolbars, just select it using the Toolbars item in the View menu
The toolbar appears free-floating at first, but you can dock it as you like in the IDE Add project Menu editor Open project save project Add form, module Properties window toolbox cut copy paste find undo redo start end break Project explorer Form layout Object browser Data view Screen location
Slide 8:THE PROJECT EXPLORER Allows to coordinate the parts of program into folders for easy manipulation.
Very useful while working for larger projects.
Pick the project you want to work on by double-clicking it.
Add and remove items by right clicking them with the mouse in the project explorer
Slide 9:THE PROPERTIES WINDOW This the place where you set object’s properties. E.g. caption of command button, text of text box etc.
When you select an object, the object’s properties appear in properties window.
The properties shown here are design time properties.
Slide 10:THE FORM LAYOUT WINDOW Using this window you can position forms as you want them to appear on the screen when they are first displayed.
Just drag that form on the form layout window to that new location.
To resize the form use a form designer window
Slide 11:THE TOOL BOX Use the tool box to add controls to your projects
Click the tool and drag the new button in the form
loaded with controls such as text boxes labels list boxes image controls etc.
Slide 12:Form Designers And Code Windows
Form designers are really just windows in which a particular form appears.
You can place controls into a form simply by drawing them after clicking the corresponding controls tool in the toolbox.
Code windows are similarly easy to understand: you just place the code you want to attach to an object in the code window (to open an objects code in the code window, just double-click that object). There are two drop-down list boxes at the top of the code window: the left list lets you select the object to add code to, and the right list lets you select the procedure to add (all the methods the object supports appear in this list).
Slide 14:Immediate Solutions
Selecting IDE Colors, Fonts, And Font Sizes
The Visual Basic IDE comes with all kinds of preset colors.
blue for keywords, green for comments, black for other code, and so on. Visual Basic allows you to decorate them.
Just open the Options box by clicking the Options item in the Visual Basic Tools menu, and click the Editor Format tab
Slide 15:Here are the text items whose colors you can select:
Normal Text
Selection Text
Syntax Error Text
Execution Point Text
Breakpoint Text
Comment Text
Keyword Text
Identifier Text
Bookmark Text
Call Return Text
Slide 16:Aligning, Sizing, And Spacing Multiple Controls
1. Hold down the Ctrl key and click all the controls you want to align.
2. Make sure you have one control in the correct position, and click that one last.
Sizing handles, the eight small boxes that you can grasp with the mouse to resize a
control, appear around all the clicked controls..
To align all the selected controls to the same left, right, or center position of the key
control, you continue with these steps:
3. Select the Align item in the Format menu, opening the Align submenu .
4. Select the type of alignment you want in the Align submenu: align the left, the center, the right, the top, the middle, or the bottom edges of the controls with the key control.
5. While the controls are still collectively selected, you can move them, if you like, as a group to any new location now that they are aligned as you want them.
Slide 17:ALIGNING NEW CONTROLS
Slide 18:SIZING CONTROLS
1.To size all selected controls, Select the Make Same Size item in the Format menu, opening that submenu.
4. Choose the appropriate item in the Make Same Size submenu to size the controls as you want them: matching the key controls width, height, or both.
Slide 19:3. Select the Horizontal Spacing or Vertical Spacing item in the Format menu, opening that submenu
4. To space the controls horizontally or vertically, select one of the items in the corresponding submenu: SPACING CONTROLS Make Equal: Sets the spacing to the average of the current spacing
Increase: Increases by one grid line
Decrease: Decreases by one grid line
Remove: Removes spacing
Slide 20:The Design Time Grid
Spacing depends on grid lines.
The grid is made up of the array of dots you see on a form at design time.
This grid is to help you place controls on a form, and by default, controls are aligned to the grid .
You can change the grid units (in twips) in the Options box when you click the General tab.
Besides setting the units of the grid, you can also specify whether or not controls must be aligned to the grid by checking the Align Controls To Grid checkbox.
Slide 21:MODIFYING THE GRID SETTINGS
Slide 22:Setting A Startup Form Or Procedure
Creating A Form-Free Startup Procedure
To start a program from code not in any form, you add a subroutine named Main() to your program. Follow these steps:
Select the Properties item in the Project menu to open the Project Properties box,
Click the General tab in the Project Properties box, select Sub Main in the Startup Object drop-down list, and click on OK.
Select Add Module in the Project menu, and double-click the Module icon in the Add Module box that opens.
Add this code to the new modules (General) section in the code window:
Sub Main()
End Sub
5. Place the code you want in the Main() subroutine.
Slide 23:THE PROJECT PROPERTIES BOX
Slide 24:Selecting The Startup Form
To specify which form is to be displayed first, You do that with the General tab of the Project Properties box.
To specify the startup form for a project, just open the Project Properties box as we have done in the previous section and select the appropriate form in the Startup Object box.
That form will act as the startup form.
Slide 25:Using Visual Basic Predefined Forms, Menus, And Projects
To add one of the predefined Visual Basic menus, follow these steps:
1. Select the form you want to add the menu to by clicking it with the mouse.
2. Open the Visual Component Manager from the Tools menu. If the Visual
Component Manager is not already loaded into Visual Basic, open the Add-In
Manager in the Add-Ins menu, click the box labeled Visual Component Manager,
and close the Add-In Manager.
3. Open the Visual Basic folder in the Visual Component Manager.
4. Open the Templates folder in the Visual Basic folder.
5. Open the Menus folder in the Templates folder.
6. Select the type of menu you want and double-click it. These are the available
menus:
Edit menu
File menu
Help menu
View menu
Window menu
7. The new menu will be added to the form you selected
Slide 26:OPENING THE MENUS FOLDER IN THE VISUAL COMPONENT MANAGER
Slide 27:ADDING A PREDEFINED MENU TO A VISUAL BASIC FORM
Slide 28:Besides menus, you can add a whole selection of predefined forms to your projects by finding the Forms folder in the Templates folder in the Visual Component Manager. List of available forms, ready to be added to your project with a click of the mouse:
Blank forms
About dialog boxes (two types)
Add-in forms
Browser forms
Data grid forms
Dialog forms
Tip forms
Log-in forms
ODBC log-in forms
Options forms
Query forms
Slide 29:in the Visual Component Managers Templates folder, you can add the
following pre-defined elements to a Visual Basis Project:
Classes
Code procedures
Control sets
Forms
MDI forms
Menus
Modules
Project templates
Property pages
User controls
User documents
After you’ve created components like these in Visual Basic, you can add them to
other projects using the Visual Component Manager and can reuse them.
Slide 30:Setting A Projects Version Information
A programs version information includes more than just the version number of the program; it also can include the name of the company that makes the software, general comments to the user, legal copyrights, legal trademarks, the product name, and the product description:
1. Open the Project Properties box in Visual Basic now by selecting the Properties item in the Project menu.
2. Select the Make tab.
3. Fill in the information you want, including the programs version number, product name, and so on.
4. Create the EXE file, which in our case is project1.exe, using the Make menu.
5. To look at the version information in project1.exe, find that file in the Windows Explorer and right-click the file, selecting Properties from the pop-up menu that opens.
Slide 31:SETTING A PROJECT’S VERSION INFORMATION READING A PROJECT’S VERSION INFORMATION
Slide 32:Setting An EXE Files Name And Icon
Select the Properties item in the Project menu to open the Project Properties box.
Select the General tab in the Project Properties box .
3. Enter the name of the project you want to use such as default.
4. The projects name will become the name of the EXE file when you create it with the Make default.exe item in the File menu.
To Set The Program Icon
The programs icon is just the icon of the startup form, and you can set that by setting that forms Icon property in the Properties window. If you have a new icon in ICO file format, you can load that icon right into that form by setting the forms Icon property to the ICO file name.
Slide 33:SETTING A PROJECT’S NAME AND ICON
Slide 34:Displaying The Debug, Edit, And Form Editor Toolbars
By default, Visual Basic displays one toolbar, the standard toolbar. However, there are other toolbars available the Debug, Edit, and Form Editor toolbars. If you want them, you add those toolbars with the Toolbars submenu of the Visual Basic View Menu just click the new toolbar you want to add. You can also remove one or all toolbars the same way.
The Debug toolbar has the following buttons:
Start
Break
End
Toggle Breakpoint
Step Into
Step Over Step Out
Locals Window
Immediate Window
Watch Window
Quick Watch
Call Stack
Slide 35:The Edit toolbar includes these buttons:
List Properties/Methods
List Constants
Quick Info
Parameter Info
Complete Word
Indent
Outdent
Toggle Breakpoint
Comment Block
Uncomment Block
Toggle Bookmark
Next Bookmark
Previous Bookmark
Clear All Bookmarks The Form Editor toolbar includes these buttons:
Bring To Front
Send To Back
Align
Center
Width
Lock Controls
Slide 36:VISUAL BASIC WITH THE DEBUG, EDIT AND FORM TOOLBARS
Slide 37:Turning Bounds Checking On Or Off
When you use arrays, Visual Basic checks to make sure that you don’t inadvertently try to access memory past the end or before the beginning of the array when the program runs, which is an error that could corrupt memory.
Here’s an example in code where we set up an array and then try to access a location past the end of it:
Private Sub Command1_Click()
Dim Addresses(1 To 10) As Integer
Addresses(1) = 1 'Fine
Addresses(11) = 11 'Problem!
End Sub
If you were to run this code, you’d get the error box unless you turn off bounds checking.
Slide 38:AN OUT OF BOUND ERROR
Slide 39:You can turn off bounds checking by following these steps:
1. Select the Properties item in the Project menu to open the Project Properties box.
2. Select the Compile tab in the Project Properties window.
3. Click the Advanced Optimizations button in the Project Properties window to open the Advanced Optimizations
4. Select the Remove Array Bounds Checks checkbox to turn off array bounds checking.
Thats itnow youve turned off array bounds checking.
Slide 40:TURNING OFF BOUNDS CHECKING
Slide 41:Managing Add-Ins
You use the Visual Basic Add-In Manager to add this and any other add-in. Here’s how to use the Add-In Manager:
Select the Add-In Manager item in the Visual Basic Add-In menu.
2. The Add-In Manager opens
3. Select the add-in’s you want and close the Add-In Manager.
That’s it now you’ve added the add-in you want. To remove it, simply deselect the add-ins box in the Add-In Manager.
Slide 42:THE VISUAL BASIC ADD-IN MANAGER
Slide 43:Adding ActiveX Controls And Insertable Objects To Projects
1. Select the Project menus Components item.
2. The Visual Basic Components box opens click the Controls tab in the Components dialog box.
3. Select the ActiveX control you want to add in the Components box, then close the Components box. The new control will appear in the toolbox.
You can also add insertable objects like Microsoft Word or Microsoft Excel objects
to a Visual Basic project by using the Components dialog box->Insertable Objects
Slide 44:THE VISUAL BASIC COMPONENTS DIALOG BOX
Slide 45:A Microsoft Excel Worksheet In A Visual Basic Project
Slide 46:CUSTOMIZING MENUS AND TOOLBARS
Here’s how you move items between menus or toolbars:
1. Right-click the menu bar to open the Customize box.
2. Next, find the menu item you want to add to another menu or to a toolbar; here we’ll move the Start menu item to the Edit menu.
3. Using the mouse, drag the menu item from the Customize dialogs Command box to the new location in a menu or a toolbar, where we drag the Start item to the Edit menu.
4. Releasing the mouse adds the menu item to its new location. Finally, click Close in the Customize box to close that dialog.
Slide 47:Add the start menu item to the visual basic edit menu
Slide 48:SETTING FORMS INITIAL POSITIONS
The Form Layout window is part of the IDE, and its default position is at the lower right in the IDE.
Setting a forms initial position couldn’t be easier. just drag the form into the new location using the mouse. If you want to know the forms exact new position, watch the first set of numbers in the toolbar those numbers record the location of the upper left of the form (in twips).
Slide 49:SETTING A FORM’S INITIAL POSITION
Slide 50:ENABLING OR DISABLING QUICK INFO, AUTO LIST MEMBERS, DATA TIPS, AND
SYNTAX CHECKING
Depending on your personal tastes, Visual Basic has a great/terrible set of features/bugs that assist/hobble you while working on your code. These features are
as follows:
Quick Info
Auto List Members
Data Tips
Syntax Checking
Slide 51:The Quick Info feature lets you know what parameters a procedure takes as you’re actually typing the procedures name. This is a useful feature that can save you time looking up parameter order or type.
Slide 52:The Auto List Members feature lists the members of an object as you’re typing the objects name. This is useful if you cant remember exactly what property you want to work with (for example, do I want the Text property, or was it the Caption
Slide 53:You can turn all of these features on and off following these steps:
1. Select the Options item in the Tools menu.
2. Select the Editor tab in the Options box
3. Select the options you want from the checkboxes: Auto Syntax Check, Auto List Members, Auto Quick Info, and Auto Data Tips.
Slide 54:DISPLAYING OR HIDING IDE WINDOWS
Want to clear some IDE Windows , Just close the windows by clicking their close buttons (the button marked x in the top right of the window).
To get these windows back, All you have to do is to select the window you want to show again in the View menu, and it’ll reappear.
Slide 56:SEARCHING AN ENTIRE PROJECT FOR SPECIFIC TEXT OR A VARIABLES
DEFINITION
To find all the occurrences of specific text throughout an entire projects used. To do that, you can use the Edit menus Find item. Selecting that item opens the Find box.
Slide 57:FINDING A VARIABLES DEFINITION.
To jump to the variables or procedures definition, just select the Definition item in the pop-up menu. This is very useful when, for example, youv’e set up a new procedure somewhere but can’t quite remember what parameters you pass to that procedure, and in what order.
Slide 58:Optimizing For Fast Code, Small Code, Or A Particular Processor
Visual Basic let you optimize your project in several different ways, and one of them is to optimize the code for size.
To optimize your program for code size or speed, follow these steps:
1. Select the Properties item in the Visual Basic Project menu.
2. The Project Properties box opens. Select the Compile tab in that box.
3. Select the kind of code optimization you want in the
" Properties box:
" Optimize For Fast Code
" Optimize For Small Code
" No Optimization
Slide 59:OPTIMIZING A PROJECT FOR SPEED OR CODE SIZE
Slide 60:ADDING AND REMOVING FORMS, MODULES, AND CLASS MODULES
The Visual Basic Project menu allows you to add these items to a project:
Form
MDI form
Module
Class module
User control
Property page
You can also add these items to a project by right-clicking any item in the Project Explorer window and selecting the Add item in the resulting pop-up menu. The Add submenu opens, and it holds the same items.
Slide 61:ADDING FORMS AND MODULES WITH THE PROJECT MENU
Slide 62:Adding ActiveX Designers
Besides ready-made objects like forms and modules, you can add ActiveX designers to the Visual Basic Project menu. These designers let you design new objects that are part of your project.
Select the Components item in the Project menu, opening the Components box
Select the Designers tab in the Components box.
Select the designer you want to add, such as the Add-In Designer, and close the Components box.
You can reach the new object designer to design the addition to your project with the Add ActiveX Designer item in the Project menu. That item opens a submenu showing the available designers, including the one we’ve just added, the Visual Basic Add-In Designer.
Slide 63:ADDING THE ADD-IN DESIGNER
Slide 64:USING BOOKMARKS
To use a bookmark, You mark a line of code by toggling a bookmark on or off at that location, and when you’re ready you can jump back to that bookmark.
Setting Bookmarks
You set a bookmark at a particular line of code by clicking that line of code and selecting the Toggle Bookmark item in the Bookmarks submenu of the Edit menu
Selecting this same item again would remove the bookmark.
Jumping To A Bookmark
You jump back to a bookmark with the two items in the Bookmarks submenu marked Next Bookmark and Previous Bookmark.
Slide 65:USING BOOKMARKS IN THE VISUAL BASIC IDE
Slide 66:USING THE OBJECT BROWSER
The Object Browser is very useful to get overviews, especially in larger
projects.
You open it by selecting the Object Browser item in the View menu or by clicking its icon in the toolbar.
Slide 67:THE VISUAL BASIC OBJECT BROWSER
Slide 68:THANK YOU