Programming Windows: Hello, Visual Basic (Premium)

Before discussing BASIC and Microsoft’s various versions of the language, I thought it would be fun to first examine how easy it is to recreate hello, world in Visual Basic, my favorite Microsoft entry. And as it turns out, it is perhaps too easy. In fact, you can recreate hello, world without writing any code at all.

This was true in 1990 with Visual Basic 1.0. And it’s still true today, as Visual Basic lives on in Visual Studio 2019, where it can be used to create Universal Windows Platform (UWP), Windows Presentation Foundation (WPF), and Windows Forms (WinForms) apps. From a code perspective, the version of Visual Basic one uses now is a far cry from the friendlier, earlier (pre-.NET) versions of the language. But since no code is really required, let’s first examine what a Hello, Visual Basic app looks like using the oldest of these still-supported technologies, WinForms.

After configuring the .NET desktop development workload in Visual Studio 2019, I created a new Windows Form App (.NET Framework) project. The resulting workspace is somewhat reminiscent of the early versions of Visual Basic, the primary difference being that the sub-windows are all grouped in the main Visual Studio main whereas classic Visual Basic versions---as you’ll soon see---used floating sub-windows.

To display the text “Hello, Visual Basic” in the application window---both in the title bar and on the window itself---all I needed to do was add a control called a label to the main application form (“window”) and then use the appropriate properties in the Properties window to set the text of each appropriately.

First, however, I needed to display the Toolbox window, a key feature of Visual Basic and its visual designers since the beginning.

This window provides a palette of Windows controls that you can add to the application form to build a user interface. And doing so is as easy as selecting a control and dragging it to the form. (You can also double-click any control to place it in the upper-left corner of the form.)

To change the title bar of the form to read “Hello, Visual Basic,” I simply selected the form itself and then found the Text property, which I changed to that text.

Similarly, to change the label to the same text, I selected that control, found its Text property, and changed that to “Hello, Visual Basic” as well. (I also changed the font size, using the Font property, to make the label a bit easier to see.

That’s it. Literally. When run, the app looks exactly like you think it should.

To be fair, we could also have done this with software code. To test this, I change the Text property for the form and the label to be blank. And then I double-clicked the form to access its Load function, which runs when the firm first loads (i.e. when the application starts

It looks like so.
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load

End Sub
Visual Bas...

Gain unlimited access to Premium articles.

With technology shaping our everyday lives, how could we not dig deeper?

Thurrott Premium delivers an honest and thorough perspective about the technologies we use and rely on everyday. Discover deeper content as a Premium member.

Tagged with

Share post

Please check our Community Guidelines before commenting

Windows Intelligence In Your Inbox

Sign up for our new free newsletter to get three time-saving tips each Friday

"*" indicates required fields

This field is for validation purposes and should be left unchanged.

Thurrott © 2024 Thurrott LLC