Hello World in Visual Basic .NET

Hello World in Visual Basic Featured Image

Lately, I’ve been targeting newer open-source languages, but I just have to veer off course a little today. That’s because Sample Programs in Every Language got it’s first GitHub contributor, Aaron LenoirOpens in a new tab.. Thanks to Aaron, we’re able to share Hello World in Visual Basic .NET.

Table of Contents

Visual Basic .NET Background

According to WikipediaOpens in a new tab., Visual Basic .NET (VB.NET) is a programming language that was created by Microsoft in 2001. Beyond that, Wikipedia doesn’t have much to offer in terms of historical information, so let’s move on.

In terms of features, however, Wikipedia has a little more to offer. For instance, VB.NET is statically typed, but the type system is both strong and weak as well as safe and unsafe.

As for syntax, VB.NET is structured which reminds me of languages like Pascal and MATLAB where blocks of code are marked by keywords—rather than braces or whitespace.

Beyond that, VB.NET has several versions. In fact, VB.NET only really refers to the language before 2005, but the syntax is largely the same today. Of course, I’ve sort of lumped them together in the same way I’ve recognized Python as one language instead of two.

Hello World in Visual Basic .NET

At any rate, let’s dive right into Hello World in Visual Basic .NET:

Public Module HelloWorld
  Public Sub Main()
    System.Console.WriteLine("Hello, World!")
  End Sub
End Module

As we can see, VB.NET is a structured language. In other words, there’s a very strong focus on code blocks and control flow structures.

Our first code block is the module declaration. In this case, we’ve declared a public module called HelloWorld. If other libraries needed access to this module, they could simply import it by name.

Next, we have our typical main function declaration. Of course, in VB.NET, we call them subroutines rather than functions—as indicated by the Sub keyword.

Finally, we have our print line. Much like languages like Java, we have to string together a few references before we can actually write to the console. In other words, we have to call WriteLine after we get a reference to the standard output class from the System namespace.

How to Run the Solution

With our solution implemented, we should probably give it a run. Perhaps the easiest way to run the solution is to copy it into an online VB.NET compilerOpens in a new tab..

Alternatively, we can run the solution using Microsoft’s very own Visual StudioOpens in a new tab.. Of course, I’m not sure of it’s support on platforms beyond Windows. Don’t forget to grab a copy of the Hello World in Visual Basic .NET solutionOpens in a new tab..

Sample Programs in Every Language

Well, I suppose that’s it for this article. Again, thanks for swinging by, and a special thanks to Aaron LenoirOpens in a new tab. for their contribution.

If you enjoyed this article, consider giving it a share. And if you really liked this article, why not contribute to the project? We can always use more help!

As for what’s next, I don’t have any plans. Obviously, there are a ton of code snippets without articles, so I’ve been tackling them one at a time.

Sample Programs in Every Language (44 Articles)—Series Navigation

For 100 Days of Code, I’ve decided to implement a few sample programs in as many languages as possible. Each implementation details a brief history of the language and a description of the code.

The plan for the series is to explore the major general-purpose language like Java, Python, C, C++, and C#. From there, we’ll take a look at some sample programs in web development languages like Ruby, PHP, and JavaScript. As we continue, we’ll cover proprietary languages like Swift and Objective-C. Eventually, we’ll start to tackle less popular languages like Rust, x86, and Verilog. Finally, we’ll play around with some of the esoteric languages like Brainf*ck and LOLCODE.

Who knows? Maybe the Sample Programs in Every Language series will become so popular it’ll never end. To help this series grow, consider sharing it on social media with your friends. Or, if you have a language you want to see, drop your suggestion in the comments.

Jeremy Grifski

Jeremy grew up in a small town where he enjoyed playing soccer and video games, practicing taekwondo, and trading Pokémon cards. Once out of the nest, he pursued a Bachelors in Computer Engineering with a minor in Game Design. After college, he spent about two years writing software for a major engineering company. Then, he earned a master's in Computer Science and Engineering. Today, he pursues a PhD in Engineering Education in order to ultimately land a teaching gig. In his spare time, Jeremy enjoys spending time with his wife, playing Overwatch and Phantasy Star Online 2, practicing trombone, watching Penguins hockey, and traveling the world.

Recent Posts