
Visual Basic.NET Programming: An Easy Way to Build Windows Apps

Disclosure: Your support helps keep the site running! We earn a referral fee for some of the services we recommend on this page. Learn more
Visual Studio is Microsoft’s flagship development product. It is an integrated development environment (IDE) designed theoretically to work with any programming language. It was originally most associated with Java (Microsoft’s now discontinued J++ language), C++, and Visual Basic.
Over the years, the number of languages has increased to support even Python and Ruby. But today it is used primarily with C# and Visual Basic .NET (VB.NET).
What’s in Visual Studio
The IDE is designed such that there isn’t much need to work outside of it. It includes the following basic elements:
- Source Code Editor.
- Debugger.
- Designer
- Windows Forms: GUI class library, similar to MFC.
- Web Editor: a drag-and-drop approach to creating webpages.
- Class Designer: a visual based tool for creating new classes.
- Database tools: a graphical tool for creating database schemas.
There are many other parts that can be used with Visual Studio. Of particular interest is Team Explorer, which allows different programmers using Visual Studio to collaborate using the Microsoft revision control system.
Visual Basic
Everyone old enough remembers what BASIC was. It was first developed in 1964 for mainframe computers — based on the early FORTRAN language. The language was made free and so soon it was everywhere, most especially on college campus computers, where BASIC was used to write some of the popular text based games of the time like Mike Mayfield’s Star Trek.
BASIC
When personal computers arrived on the scene, BASIC was an obvious language to include because it was simple to use. In fact, Bill Gates and Paul Allen got their start writing a BASIC interpreter, which they leveraged into writing the operating system for the new IBM PC. Similarly, the Commodore 64 used an operating system that was little more than a BASIC interpreter. The BASIC code of that time looked something like this:
10 LET N = 0
20 LET N = N + 1
30 PRINT N
40 IF N = 8 THEN GOTO 60
50 GOTO 20
60 END
It did have the advantage of being very clear. Most people without any programming experience can figure out what it does. Over time, BASIC became something of a joke in the computer world. But even during that time, things were changing. For one thing, BASIC became Basic. Gone were the line numbers, in were real functions. And Basic compilers showed up on the scene — things like Borland’s Turbo Basic. But this was the tail end of the technology trend. With the rise of compiled languages like Pascal and C, BASIC became relegated to hobbyists — and just the beginners at that.
Visual Basic
Visual Basic changed all that. It came out in 1991. It seems that Microsoft had originally thought of it as a hobbyist language — even if a far more cool one than those that had come before. At first, it was used as something of a semi-professional tool by people in small businesses who needed specialized software. By 1996, Microsoft released VBScript, which allowed people to automate things like Office applications — a great improvement over traditional macro languages. And then things really changed.
Visual Basic .NET
In 2001, Microsoft released Visual Basic .NET. It is one of two languages (the other being Visual C#) that have been built specifically to work with the .NET Framework. It is basically a class library that makes creating Windows-based applications much easier than they would normally be.
To be honest, Visual Basic doesn’t look much like the original BASIC language. Over the last two decades, there has been a strong tendency for all languages to start to look alike. But Visual Basic does maintain a very straightforward syntax that is easy to write and to understand. Here’s an example from the Microsoft Developer Network (note that anything following an apostrophe is a comment):
‘ Allow easy reference to the System namespace classes.
Imports System
‘ This module houses the application’s entry point.
Public Module modmain
‘ Main is the application’s entry point.
Sub Main()
‘ Write text to the console.
Console.WriteLine (“Hello World using Visual Basic!”)
End Sub
End Module
Visual Basic Versions
Visual Basic has been through a lot of versions, and the numbering is a bit confusing because versions are referred to both as their number and their year. Here is a general overview:
- V01 (1991): It was the first version of the product. The following year, Visual Basic for DOS was released, but it was actually the newest version of Microsoft’s IDE QuickBASIC and not actually compatible with the Windows version.
- V02 (1992): It was mostly a cosmetic upgrade with increased speed.
- V03 (1993): This version introduced the Jet Database Engine.
- V04 (1995): This was the first version that could create 32-bit applications. It also replaced VBX with OLE controls.
- V05 (1997): It was the first 32-bit only version of Visual Basic. It allowed users to create ActiveX controls.
- V06 (1998): This version supported the creation of client and server side web applications and many new database functions including full support of ActiveX Data Objects.
- V07 (2002): This was the first .NET version of Visual Basic based on the .NET Framework 1.0.
- V08 (2005): This version solidified Visual Basic as a .NET language. In keeping with this, the “.NET” was dropped from its name so that it was “Visual Basic” just as C# was simply referred to as “C#.”
- V09 (2008): This was an upgrade that went along with .NET Framework 3.5.
- V10 (2010): This update brought Visual Basic more in line with C#.
- V11 (2012): This version introduced asynchronous computing and updated to .NET Framework 4.5.
- V12 (2013): This version was basically just Visual Basic 11 with Visual Studio 2013.
- V13 (201?): This version was skipped by Microsoft to make the numbering of Visual Basic and Visual Studio the same.
- V14 (2015): This is the newest version of Visual Basic and the first to be open source.
Getting Started
In general, if you are going to developing Visual Basic applications, you will be using Visual Studio. The two go together. However, getting exactly the tools that are used in these tutorials may be difficult. In general, it shouldn’t be a problem using different versions given that these resources are dealing with the core facilities of both the language and the IDE.
- Getting Started with Visual Basic: Microsoft’s page of links for getting started with Visual Basic using Visual Studio 2015.
- Visual Basic .NET Tutorials: a great introduction to Visual Basic, the .NET framework, and Visual Studio.
- Visual Basic 6 Tutorial: a good introduction to Visual Basic 6, but it also includes links to tutorials for all versions from 9 (2008) through 14 (2015).
- Getting Started With Visual Basic 2008 (pdf): the first chapter of Evangelos Petroutsos’ book, Mastering Microsoft Visual Basic 2008.
- Microsoft Visual Basic Tutorials: a couple hundred very clear tutorials on Visual Basic and related subjects.
- Free VB .NET Course: a thorough introduction to Visual Basic that doesn’t assume any prior knowledge.
- How To Start Programming: a series of 56 short videos which take you from downloading Visual Basic 2008 to concepts like exceptions and classes.
- VB.Net Tutorial: a basic tutorial that is quite thorough.
Advanced Tutorials
Visual Basic is such a vast subject that it is impossible for any resource to deal with all elements of it. But the following will get you started with some more advanced aspects of the language once you master the basics.
- Microsoft’s Visual Basic Page: contains links to a tremendous amount of information for Visual Basic with Visual Studio 2015.
- Tutorials Point: various tutorials, some of them basic but others more advanced.
- Free Tutes Advanced VB6 Tutorial: although pre-.NET, these tutorials deal with a lot of important things like COM and ActiveX Controls. They also have .NET tutorials.
- Net-informations.com Visual Basic .NET: contains loads of basic tutorials, but more important, advanced topics like ADO.NET and GUI programming.
- FunctionX Visual Basic .NET Page: tutorials on all parts of Visual Basic along with a number of advanced examples.
- C# Corner’s Visual Basic .NET: advanced Visual Basic examples. Quite interesting!
- Object Oriented Programming In VB.NET: a Visual Basic tutorial with the focus on its object oriented natural. Probably not a good choice as a first introduction to the language.
- Wonder How To VB.NET: Visual basic examples demonstrated with videos.
Books
There is a tremendous literature on Visual Basic and Visual Studio. Many of the following books are parts of a series and may have editions for earlier versions of the system if that is what you are using. But as with the basic tutorials, you will generally be okay using a resource that isn’t specific to what you are using.
- Beginning Visual Basic 2015 by Bryan Newsome: geared toward people who are totally new to programming. This book has editions going back to Visual Basic 2008.
- Visual Basic 2015 in 24 Hours by James Foxall: an introduction to Visual Basic from the very beginning. This book has editions going back to Visual Basic 2005.
- Learning Visual Basic .NET by Jesse Liberty: an old book, but still an excellent introduction to the Visual Basic programming language.
- Professional Visual Basic 2012 and .NET 4.5 Programming by Sheldon et al: thorough introduction with a number of advanced topics.
- Visual Studio 2015 For Beginners by Lewis Edwards: a very short introduction to Visual Studio.
- Professional Visual Studio 2015 by Bruce Johnson: the ultimate reference for everything that Visual Studio can do. It starts at the beginning and covers everything. It is also available in 2012 and 2013 editions.
Tools
Visual Studio provides all the tools that you would normally need. But there are various add-ons and extensions that you might find useful under some circumstances.
- Visual Basic 6 Quick Reference: a basic reference on a single sheet of paper — handy for pinning to the wall.
- Development Tools and Languages: links to all of Microsoft’s development tools including Visual Studio and SDKs.
- Visual Basic Tools for Visual Studio: a service that allows you to code classic Visual Basic inside the most recent versions of Visual Studio.
- MZ-Tools: a commercial Visual Studio add-on that offers customizable code templates, specialized designers, and much more.
VBScript
VBScript is a proprietary scripting language developed by Microsoft and based on Visual Basic. It was designed and released in the mid-1990s, primarily as a light-weight scripting language for use in Microsoft environments. It was also intended early on as an in-browser language, as an alternative to JavaScript.
VBScript History
VBScript was developed at Microsoft about the same time as JScript, which was Microsoft’s implementation of the JavaScript language. They were both targeted primarily at web developers initially. VBScript, however, because it had an API linked to the host environment (called COM, or Component Object Model), and because it was fairly easy to use, quickly gained usage among Microsoft system administrators.
As VBScript’s popularity increased, it found its way into just about every Microsoft environment available. Also, the language expanded, to include regular expressions, object-oriented programming principles, and other advanced features. By version 5 of the language, it was capable of doing just about anything other major languages were capable of.
With the advent of the .NET framework, Microsoft decided to fold VBScript into that framework. Due to its inclusion in .NET, VBScript is nearly universally available in Microsoft environments.
Interestingly, for as much as VBScript has expanded its reach over the last two decades, there is one place where it is no longer available: the browser. VBScript was never available in non-Microsoft browsers. The last version of Internet Explorer to include support for VBScript was version 10. Internet Explorer 11, and the new Microsoft Edge browser, do not support VBScript. (Actually, it is possible to run VBScript in Internet Explorer 11, if you turn on compatibility mode. But this isn’t recommended.)
VBScript Primary Uses
VBScript is a general-purpose scripting language, and could, in theory, be used for any number of purposes. However, most VB script usage falls into a small handful of categories:
- Systems administration: administrators of various Microsoft systems were among the first adopters of VBScript, as it was a marked improvement over earlier alternatives. It continues to be used by sysadmins, and its use is somewhat analogous to the use of Bash or Perl among Linux administrators. VBScript is beginning to be displaced by PowerShell in this area, but VBScript continues to be used quite a lot.
- Testing: VBScript is used in Quick Test Professional (now called Unified Functional Testing), a popular unit testing suite.
- Embedded devices” VBScript is also relatively popular among developers of embedded applications (user interaction software built into custom purpose devices).
- Macros and in-app scripting: VBScript also gets a fair amount of use within other Microsoft applications, such as MS Office.
VBScript and Web Development
VBScript was originally targeted at web developers, both for client-side (in-browser) and server-side scripting. With JavaScript’s rise to dominance, VBScript’s use in the browser was never anything more than marginal. It did get some use for server-side development in the context of Microsoft’s Active Server Pages (APS), which could run VBScript scripts via a .dll
.
Even though in-browser use has been scant (and is no longer supported), the browser-based features of VBScript can be exploited in the context of HTML Application, a Windows app format that allows a desktop UI to be built in HTML and powered via one or more scripting languages. This approach is fairly popular among Windows sysadmins and developers, as it allows them to get a prototype up and running pretty fast. (This desktop use of HTML dating back to the late 1990s prefigures the rise of modern app engines like Electron , NW.js , and PhoneGap).
VBScript Language and Examples
Below we will provide a very basic introduction to the language.
Features
VBScript is primarily a functional language. It supports classes and objects, but not dogmatically so. Early versions of the language did not support classes and other object-oriented features. Standard logic and control-flow structures are available, as are a wide variety of data types.
The main “unit” of programming is the procedure. There are function procedures and sub procedures. Sub procedures do not return a value, but can perform actions.
Unlike Visual Basic, VB does not have much ability to define a GUI. It can create simple popup alerts, but a form-based application would need something like HTML or XML to define the UI.
Environment
VBScript has to be run in a supported environment. For server-side web development, that environment is ASP. For systems automation, it is usually the Windows Script Host.
Syntax
VBScript was based on Visual Basic, so its syntax is most similar to that. Visual Basic was based on BASIC, and retained many syntax features from that language. If you learned to program in BASIC, VBScript will probably look at least somewhat familiar.
VBScript syntax looks a little bit like JavaScript, but there are enough differences that it can be easy to get tripped up. Similarities include dot-notation for accessing the Component Object Model that looks a lot like accessing the Document Object Model in JavaScript.
Variables should be declared using the dim
keyword before they are used. You can specify the variable type, or leave it undefined until a value is assigned.
Dim greeting
Dim recipient As String
Dim message
greeting = "Hello"
recipient = "World!"
message = greeting & " " & recipient
document.write(message)
Unlike JavaScript, variable names are case-insensitive (as is most of the language), and semi-colon terminators are not requires — line breaks serve as statement terminators.
Comments in VBScript are single-line only, and are defined by a leading single apostrophe ( '
).
' This is a comment.
Functions, procedures, if
statements, and other code-blocks are declared with a key word statement and ended with the end
statement.
'simple if statement
if x > y then
wsh.echo "X is Greater"
end if
VBScript Resources
- Books
- Online
Should I Learn VBScript?
If you are an IT professional or Systems Administrator working in a Microsoft environment, you probably should be familiar with VBScript, and its use as a system automation tool. Even though you can use PowerShell and other languages, you will likely encounter older automation and testing scripts written in VBScript, which you will need to maintain, debug, or rewrite.
Summary
Visual Basic and Visual Studio are very big subjects. If you are programming in a Windows environment, they provide you with the power to do whatever you want. Using the resources presented here, you can get started and go a long way. You just need to dive in.
Text written by Frank Moraes with additional content by Adam Michael Wood. Compiled and edited by Frank Moraes.
isaiah t
September 11, 2019
To convert vb6 to web enabled apps using asp.net of visual studio. How are available are the tools without complete rewrite of the vb6 codes to asp.net of vb.net.