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.
Sign Up for our Free Newsletters
Thanks, You're in!
Visual Basic Categories
- "How to do it" Programming Techniques for Visual Basic .NET
- Learn VB.NET - Visual Basic for the New Millennium
- Find the Visual Basic Book You Need
- ASP.NET with Visual Basic Hub Site
- Quick Tips for VB Programmers
- Program Microsoft Office Applications
- Framework Tools for .NET
- Threading and Multiprocessing
- Blog
- Syntax, Concepts, and Diversions for Visual Basic Programmers
- Explanations for the new Visual Basic programmer
- VB Tutorials That Inform
- Updated Articles and Resources
Visual Basic Essentials
79 Articles in: Programming Visual Basic Quick Tips for Programmers
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.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.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.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 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.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.How to Use "VB.NET" "DIM" Statements to Decalre Variables in Visual Basic
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 How 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. Starting with a Boolean and an Integer, this article shows exactly what happens and why. It's a great exercise that will ensure that you understand exactly how they work.Dynamically Load Objects From Class Libraries
You can dynamically load a member of a class library to give your program more flexibility. I decided to document this Quick Tip when I discovered that VB and C# seem to require slightly different FullName parameters, and there wasn't any other documentation to be found about it.Formatting Controls - Using the Primary Control
Visual Studio has excellent ability to help you format controls on forms. But there are just a few corners that can be confusing, especially when you're trying to format a complicated form. This Quick Tip shines a light in those corners by explaining them.Formatting Controls - Using the Primary Control
Visual Studio has excellent ability to help you format controls on forms. But there are just a few corners that can be confusing, especially when you're trying to format a complicated form. This Quick Tip shines a light in those corners by explaining them.Objects, Parameterized Constructors, Anonymous Types and the With Keyword
The With Keyword, Object Intialization, Anonymous Types and Parameterized Constructors are all covered well at Microsoft. But they don't cover the way that all of these techniques interact. About Visual Basic does in the Quick Tip.Public Class Variables Versus Class Properties
A property of an object can be coded in the class that defines the object as either a Property or a Public variable in the class. This Quick Tip tells you when to do which one. If your New constructor isn't working and you can't figure out why, this tip also documents a bug that might explain the problem.Validating a Numeric String in VB.NET
This Quick Tip shows how to write the code that will guarantee that a string, such as input through a TextBox, is an strictly numeric characters, such as "12345". I needed this to make sure that input from a TextBox didn't contain any spaces or other characters.A Guide to Drag and Drop
Drag and Drop can be programmed relatively easily in VB.NET, but it doesn't work unless all the components involved work together. This Quick Tip shows how it's done with different scenarios, including using a custom cursor and modifying the object being dragged before it's dropped.A Guide to Programming AutoComplete
AutoComplete is a convenience that nearly any program that uses data - and that's virtually all of them - can use. For Windows forms, it's built into the ComboBox and TextBox controls. This Quick Tip shows how to write the VB.NET code. Bonus: There's a performance killing way to write the code that should be avoided. We tell you what it is.AutoScrollOffset
AutoScrollOffset, along with a companion method ScrollControlIntoView, are not a part of .NET that programmers are likely to know really well. This Quick Tip looks at how they work and the initial conclusion is: Not very well. If you would like to play with them yourself, the article includes downloadable code to use for your own experimentation.Unblock Downloaded Zip Files
Downloaded source code files are normally blocked. That means that a bit tells programs such as Visual Studio that the files have not been authenticated and might contain something dangerous. Usually, this is just an irritation because you actually do know what is in the files. This Quick Tip shows how to unblock the files while unzipping them...Versions of Your Programs
When it was introduced, .NET provided an easy way to mark each version of your program with a "Major, Minor, Build, and Revision" number. But it seems that every good thing gets complicated and that has happened here too. There are three of these numbers now and they can all be different. And there are at least four places where you will see...A Quick ListView App
A reader asked a question about using the Dictionary object. Like a lot of questions, this seemed to be more a design question than a syntax question. Using ListView is a better solution. This Quick Tip shows how to solve his problem and also illustrates another use of binary serialization (BinaryFormatter).Using For-Each to Iterate Through a Multidimensional Array of Different Types
Multidimensional arrays have always been obscure, and they're normally not the "today" way to do things. Today we normally use collections or datastores like a database or XML. I ran into an interesting dark corner of multidimensional arrays: It appears that it is now possible to assign different types to the same multidimensional array and even...
View More

