Welcome to the final “What’s In YOUR App?” post of the series.

  • Java
  • C#
  • PowerShell
  • Visual Basic

Those of you who have been around computers, for a significant amount of time, likely remember the days when BASIC (Beginner’s All-purpose Symbolic Instruction Code) was a popular programming language. It was found in calculators, handheld devices like 1982’s Epson HX-20, and even included in ROM in some of the early IBM PS/2 Portables (such as the L40 SX). Before the generally accepted concept of commercial software, and way before the concept of shareware, the populace’s mindset was “Who would want a computer that they couldn’t program to do what they want?” In addition, BASIC continues to be taught in a wide variety of schools, as an entry-level programming language.

Perhaps the most popular implementation in the early 1990s was QBASIC, later sold with a compiler as Microsoft’s QuickBasic. This was a popular way for power computer users, and programmers, to write utilities for MS-DOS. Around 1991, Microsoft decided to harness the power of Microsoft Windows (and the rapidly proliferating GUI Concept in general), and released Visual Basic 1.0 for Windows. Around the same time, it released Visual Basic for DOS, although this never really caught on (there was only one version of VBDOS ever created!)

Visual Basic was sold alongside Visual C++ (Microsoft’s implementation of a development environment for C++), both as a standalone product and a component of Developer Studio (later referred to as “Visual Studio”). It continued to be updated and sold in its original form until 1998, when Visual Basic 6.0 was released. After VB6, Microsoft’s .NET platform took over, and Visual Basic (starting with Visual Basic .NET) simply acted as a “wrapper language” to Microsoft’s MSIL intermediate language. However, there seems to be a silent majority of users that prefer the “classic” Visual Basic 6.0, and in May 2014 it actually overran C# as the more popular Microsoft programming language.

So what does a modern Visual Basic .NET program look like? Here’s the code:

And here’s the screenshot:
helloworld-vb

Keep in mind, as usual, I’m only showing console versions of applications. You can easily create mouse-driven GUI applications with Visual Basic – in fact, this was its intended use – but for consistency with all other Hello World examples, I’m showing the console version.

Let’s break this code down into sections.

In Visual Basic, sections of code (and variables) can be grouped into modules. These are different than classes by nature, since you do not instantiate these; you simply make a reference to them. You might have a module called SoundCode, with public Subs (subroutines) for PlaySound and StopSound. To call these, from anywhere in your code within scope, you would simply call SoundCode.PlaySound, without first having to create a SoundCode object.

In Visual Basic, a “Sub” (as mentioned above, short for “subroutine”) is a logical block of code that can be executed by name, either with or without arguments. Subs do not return any value, as they are the equivalent of void in Java and C#; if you want to return a value, you would use a Function.

This is the first actual command that gets executed. It prints “Hello, World!” to the standard output stream, which, in this case, is the console/screen. Note that there are no semicolons ending each line or command; Visual Basic was intended to appear more like a naturally spoken language than a programming language.

In Visual Basic .NET, you must end each command with ( ) even if you aren’t passing it any arguments. In the “classic” Visual Basic, this line would have simply looked like Console.ReadLine (if VB6 even had a Console class, which it didn’t by default.) In any event, this pauses the output and waits for the user to input text (in this case it serves as a “Press Enter to continue”.)

Each of these languages has a fairly clear purpose in the world. I started with Visual Basic and I suggest you do as well, especially considering its recent boost in popularity. Nonetheless, this blog will continue to focus on C# as that is the predominant language in industry.

Share

Comments are closed.

Post Navigation