1. Home
  2. Computing & Technology
  3. Visual Basic

Quick Tips for VB Programmers

Need a fast answer to a specific question? Here's a collection of past answers to Visual Basic programming questions that might have your answer.

Fixing the InputBox

A reader asked for help using InputBox to code a loop to input data to a ListBox control. The InputBox is a VB6 holdover function that probably shouldn't be used. Another article that is linked in this one shows why and what to do instead. But this article shows how to use unmanaged code to solve one problem with the InputBox: You can't tell the difference between blank input and the Cancel button.

Getting Input and Validating It

A reader asked for help coding a loop to input data to a ListBox control. The problem was that the reader was using the holdover InputBox from VB6. There are better ways and this Quick Tip shows one of them: the Validating Event of a TextBox control.

Predicate Explained

"Predicate" expressions, an integral part of VB.NET 2008 Lamda expressions, are explained in this Quick Tip.

Use a VBA Macro To Change the Background of a Cell

A reader asked how to change the background color of an Excel spreadsheet cell with VBA macro code. The answer involved some techniques that could come in handy for more than just this. This Quick Tip explains it all.

Display a PDF With VB.NET

PDF is an Adobe format for presenting documents. But since Adobe is a competitor to Microsoft, there's uneven support for the format in Microsoft products. You can save Office files as PDF files, but Microsoft doesn't provide any software tools for integrating the format into systems created with VB.NET. But you can do it anyway. This Quick Tip shows you how.

Anonymous Types - What and How

Anonymous types are a quicker way to use objects, but some of the tricks in using them are not obvious. This Quick Tip explains it all.

Object Initializers - A New Feature of VB.NET 2008

VB.NET has a quicker way to initialize data objects. This Quick Tip shows you how to do it with both parameter based constructors and anonymous types.

Events - Program and Handle Your Own Unique Event in VB.NET

Handling events that are made available to you by other objects is easy. Mainly, you just have to select the event in the code window and add some statements to the event subroutine that is automatically created. But what if you want to create your own event? This Quick Tip shows you how.

Write Programs That Run When a File is Added, Changed, or Deleted

The FilesystemWatcher component makes it easy to write programs that run when a file has been added, deleted, or just changed.

Accessing a Secure Web Site Using VBA

A reader asked if VBA could be used to login to a secure web site using HTTPS and SSL. The answer is yes ... and no. This Quick Tip explains what that means.

Use The Registry To Find The Path To A Program In VB.NET

A reader asked for help finding a way to determine the path to installed software. This Quick Tip not only shows how to do that, it can serve as an introduction to working with the Windows registry in general using VB.NET.

Programming Control Arrays in VB.NET

The lack of VB6 Control Array in VB.NET is by far the most popular single topic at About Visual Basic. A lot of programmers remember the convenience of simply dragging and dropping multiple controls onto a form and then addressing them as an array of controls. The topic attracted ideas from programmers for years after the original article that I wrote about it. This article is a summarization of all of the ideas received about the best way to program something similar in VB.NET.

The Equals and ReferenceEquals Methods of the Object Object

The root of the .NET Framework contains six public methods and two of them are used for testing equality: Equals and ReferenceEquals. This article explains how those two work.

The ToString Method

The ToString method is one of the fundamental methods in the root of the entire .NET Framework. That makes it available in every other object. This quick tip shows some of the ways ToString can be used.

The Object Object

The Object object is the root of the entire .NET Framework. That means that the methods and properties of Object are available all the time and in every .NET Framework object because everything inherits from Object. This Quick Tip tells you about it.

Block Level Scope in VB.NET

VB.NET uses what is called block level scope for variable declarations. This article shows what it is, and also explores some dark corners that you might run into when you use it.

Open a Web Document at a Specific Location

A reader asked for help finding a way to open a specific location in an HTML document using the # marker in a URI. (As in file:///C:\webdoc.htm#location). The reader was trying to use Process.Start(). This doesn't work. But WebBrowser.Navigate() does.

The Region Directive in VB.NET

In the very first edition of VB.NET, compiler generated code was kept in a hidden Region section to protect it from being accidentally changed. When Framework 2.0 was released, Microsoft started using partial classes to do the same thing. But the Region directive is still available to programmers to use to make their own code better organized and easier to read. This Quick Tip shows you how to use it, and why.

ErrorProvider - A Visual Control For Windows Forms

The Windows Forms libraries in Visual Basic .NET includes a number of convenient provider components. One of these is the ErrorProvider component that pops up an icon to tell the user that something is wrong when your program is validating user input. This Quick Tip tells you how to use it.

Arrays: The Difference Between Jagged Arrays and Rectangular Arrays

There are two ways that you can declare an array in Visual Basic. You can declare it as a multidimensional rectangular array or a jagged array. There are some very important differences and this Quick Tip explains what they are.

How a VB.NET Structure Is Different From a Multidimensional Array

A structure and a multidimensional array have a lot in common in Visual Basic .NET programming. Often, you can use either one and your program will work just as well either way. But there are some clear differences. This Quick Tip helps you understand both of them so you can manage information inside a program better.

Friend and Protected Friend in VB.NET

Visual Basic .NET is completely OOP (Object Oriented Programming) because it supports inheritance, the major thing that previous versions of Visual Basic did not support. And because it supports inheritance, it also has two new access modifiers: Friend and Protected Friend. This Quick Tip introduces them to you.

Using Shared Access in Visual Basic .NET

When you instantiate, that is, "make a copy," of an object in VB.NET, it usually means that the members in the instance are unique from any other copies. But some members can also be Shared. This Quick Tip shows you what that means.

The SOOPercharged VB.NET sender and e Parameters

The sender and e parameters passed by the system to standard VB.NET event subroutines are key elements in your programming toolkit. It's all part of the new sOOPercharged VB.NET. This Quick Tip explains how to use them.

VB.NET and Recursion

Recursion is a valuable programming technique and when a programming problem requires this technique, nothing else quite works. But there is a hidden trap in recursion that you need to know about: It can eat memory resources like nothing else. This Quick Tip explains it.

VB.NET's Logical Operators AndAlso and OrElse

VB.NET features two logical operators "AndAlso" and "OrElse" that weren't in previous versions. They do a lot more than the old "And" and "Or". This Quick Tip shows you what they can do.

The VB.NET Imports Statement

The actual effect of the Imports statement in VB.NET is often a source of confusion for people learning the language. And the interaction with VB.NET References makes for even more confusion. This Quick Tips article clears it up.

NaN, Infinity, and Divide by Zero in VB.NET

There are some unique and unexpected ways that the "divide by zero" problem is handled in VB.NET. This article explores what they are and how the NaN (Not a Number) and Infinity VB.NET constants should be coded.

Declaring Variables in Visual Basic .NET

Visual Basic .NET encourages you to be very explicit in declaring variables. In fact, 'Option Explicit' is the default in VB.NET. Complex variable declarations are possible and declarations do what you expect them to. Read this Quick Tip to understand more about how to declare variables.

Understanding VB Logical Operators Work Bitwise

The VB logical operators AND, OR, NOT, and Xor do something interesting when they're evaluated 'bitwise' in VB.NET with a Boolean and an Integer. This article uses Xor to illustrate exactly what happens and why. It's a great exercise that will ensure that you understand exactly how they work.

Use CreateShortcut in VBScript to Manage Your Desktop

A really fast Quick Tip about a very useful object that you can use in VBScript - Visual Basic Script - to manage your desktop; the CreateShortcut object.

DEBUG and TRACE in VB.NET

Debugging in VB.NET usually means using the Debug icons to single-step your program and maybe a few breakpoints. But there are a lot of little known things about debugging. This quick tip shows just a few of the more useful ones.

Setting Tabs in VB.NET and VB6 Forms Components

An About Visual Basic reader asked: How can I align colums in a ListBox. VB6 doesn't provide a convenient way. You can do it in VB.NET but VB6 requires API calls. This article shows both ways, and it also shows you how to call the API.

Convert Text to Number in Excel

The advice on the web that tells you how to convert text to numbers in Excel doesn't work. The advice here does. Tested in Excel 2003 and Excel 2007.

Selecting the Components Used in the VB6 Package and Deployment Wizard (VB6)

Selecting the Components Used in the VB6 Package and Deployment Wizard (VB6)

Send and Receive EMail using Visual Basic

An About Visual Basic reader asked: How do I use Visual Basic to send and receive email?? A question and answer from About Visual Basic.

Using the Package and Deployment Wizard (VB6)

An About Visual Basic reader asked: How do I use the Packaging and Deployment Wizard to create files and folders when the user installs my application? A question and answer from About Visual Basic.

Processing a Web Page in Visual Basic

An About Visual Basic reader asked: How do I use Visual Basic to access the HTML code of a website? A question and answer from About Visual Basic.
Explore Visual Basic
By Category
About.com Special Features

Holiday Central

What to eat, where to go, fun things to do and how to save money on the perfect gifts. More >

Family Tech Center

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

  1. Home
  2. Computing & Technology
  3. Visual Basic
  4. Quick Tips

©2009 About.com, a part of The New York Times Company.

All rights reserved.