Cheat Sheet

Visual Basic 2008 For Dummies Cheat Sheet

From Visual Basic 2008 For Dummies

By Bill Sempf

Visual Basic is a much-used programming language, and Visual Basic 2008 makes using it easier than ever. The My object helps you look through the layers to see the whole structure. And, you get access to keyboard shortcuts and can customize options to suit yourself.

Using the My Object in Visual Basic 2008

The most impressive single language feature in Visual Basic 2008 is the My object. The My object is an object that exposes commonly used .NET technology through an easy-to-understand hierarchy. In short, it is a set of shortcuts into the .NET Framework.

The following table highlights the core classes and common functionality of the My object:

My Object Class Name What It Does Cool Functionality
My.Application Returns information about and services provided by the current
running application.
The NetworkAvailabilityChanged event is fired when the
computer running the application connects to or disconnects from
the network.
My.Computer Provides access to resources, devices, and data related to the
computer running the application currently.
Look at My.Computer.Clipboard for methods like
GetText(), which reads from the Windows Clipboard.
My.Forms Provides everything you need to know about all of the forms in
the current project.
My.Forms allows you to use Visual Basic 6–like
functionality built into Windows Forms.
My.Log Grants access to the ASP.NET application log listeners, which
can handle log entries in a myriad of ways.
Look at the <listeners> section of the
Web.Config file, where you can determine where the Log class
is writing to.
My.Request Provides access to the current Web request for ASP.NET
Use My.Request to see ASP classic-type access to the
Request, such as My.Request.Headers (the HTTP Web
header collection).
My.Resources Exposes global application resources. Change the form icon (to show a change in status, for example)
with My.Resources.Form1Icon.
My.Response Grants access to the current Web response for ASP.NET
Use My.Response to see ASP classic-type access to the
Response, like My.Response.Write.
My.Settings Gives the ability to store and retrieve the application-level
settings for the current program.
Change application-level settings at runtime (finally). Set up
the settings in the Application Project Designer, and then use
My.Settings.SettingName to change it at runtime.
My.User Provides security context information for the user logged into
the computer using the application.
Personalize your application with the current user’s
name. Check out My.User.Name.
My.Services Provides access to the Web services referenced by the
After you have referenced a Web Service, you can call it with

Keyboard Shortcut Keys for Visual Studio in Visual Basic 2008

A ton of shortcut key combinations are built into the Visual Studio feature of Visual Basic 2008, and you can feel free to use them all. You can also make your own keyboard shortcuts in the Options dialog box by choosing Tools→Options and then clicking Keyboard in the tree view on the left. The following table includes some useful shortcuts, may of which work in any Windows application.

Visual Studio Element Keyboard Shortcut What Happens When You Use the Shortcut
Build Ctrl+Shift+B The most handy keyboard shortcut in the entire system, this key
combination compiles your solution.
Full Screen Shift+Alt+Enter When you are mostly writing code, it is sometimes handy to fill
the entire screen with the code window.
Close application Alt+F4 Closes the Visual Studio window. (Works for other applications,
Close document Ctrl+F6 Closes the active application document.
Shortcut menu Shift+F10 Displays the context-sensitive shortcut menu for whatever is
actively selected (such as the Toolbox or Solution Explorer).
Show Properties window F4 Shows the Properties window — arguably one of the most
common windows you need on a moment’s notice.
Toggle tree focus selection Ctrl+Spacebar Toggles a selection for the current focus in tree view.

How to Modify the Options Panels in Visual Basic 2008

You can change almost everything about how you use your programming environment from the Options dialog box in Visual Basic 2008. Take the time to familiarize yourself with this handy dialog box and set up your environment for just the way you like to work.

You get to the Options dialog box by choosing Tools→Options from the main menu. You navigate through the various options screens using the tree view on the left side. To show the total of all of the options, check the Show All Settings check box in the lower-left corner of the Options dialog box. The following table gives you a rundown of the amazing amount of stuff you can alter from this one spot.

IDE Element Where You Set It What It Does for You
Tab sizes Text Editor – All Languages – Tabs Lets you specify the tab sizes for Visual Basic code (or any
other language in Visual Studio, for that matter)
SQL Parameter Prefixes Database Tools – Query and View Designers When Visual Studio creates SQL parameters, it will add these
prefixes to the names to meet with your standards.
Comment Tokens Environment – Task List These are the phrases that you can begin comments with in order
to add them to the task list.
Opening view HTML Designer – General When you open an ASPX or HTML file, you have a choice to see it
in the Designer View or the Code View.
Source control login Source Control – Plug-in Settings If you are using Source Safe, you can set your username
AutoRecover timing Environment – AutoRecover In case of blackout, you can set how often Visual Studio saves
your code in an AutoRecover file, just like what happens in
Viewing Help Environment – Help – General In Visual Studio, the Help is actually a totally separate
application. You can view it inside Visual Studio by changing a
setting here.
VB code options Projects and Solutions –VB Defaults If you like your code compiled with Option Explicit or Option
Strict by default, you can set it here.
HTML Formatting Text Editor – HTML – Formats If you don’t like the editor adding the close tag to HTML
elements for you, you can turn that off here.
Startup Actions Environment – Startup You can set the last project you worked on to load
automatically here, as well as customize the RSS feed that the
Start page uses.
Online Help Environment – Help – Online When you aren’t connected to the Internet, you may not
want the Help software to check online. You can change the option