Skip to content
AgileLogics
4 min read

Setting Up Your Environment

Prerequisites: Installing Visual Basic

Editor

  • Visual Studio (Windows) — the best experience for Visual Basic: IntelliSense, the Windows Forms designer, a debugger, and refactoring. The free Community edition is enough.
  • Visual Studio Code — works for console apps with the C# Dev Kit extension's .NET tooling, but Visual Basic support there is basic.
  • JetBrains Rider — supports Visual Basic projects too.

Create a project

dotnet new console -lang VB -o HelloVB
cd HelloVB
dotnet run

This creates HelloVB.vbproj (the project file) and Program.vb, and dotnet run compiles and runs it:

Hello World!

Turn on Option Strict

Visual Basic has three compiler options that you should know from day one:

Option Default What it does
Option Explicit On every variable must be declared with Dim
Option Infer On Dim x = 5 infers the type (Integer)
Option Strict Off when On, forbids risky implicit conversions and late binding

With Option Strict Off, VB silently converts between types — even "abc" to a number, which fails only when the program runs. Turn it on for every project by adding one line to the .vbproj:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <RootNamespace>HelloVB</RootNamespace>
    <TargetFramework>net10.0</TargetFramework>
    <OptionStrict>On</OptionStrict>
  </PropertyGroup>
</Project>

All examples in this course are compiled with Option Strict On. (You can also put Option Strict On as the first line of a single file.)

Imports you get for free

A VB project automatically imports common namespaces — System, System.Collections.Generic, System.Linq, System.Threading.Tasks, and a few more — so you can write Console and List(Of T) without an Imports line.