Visual Basic Features in Visual Studio 2022

Most articles cover new features specifically tailored to C#, its improvements, and the C# development environment. Finally, with Visual Studio 2022, comes a lot of changes to the Visual Basic environment and we are going to go over most of the new features for VB in this quick .NET article.

VB Features in VS Studio

Below are some the new features tailored towards Visual Basic developers in the new update to the Visual Studio integrated development environment (IDE).

VS Studio Editor Font Cascadia

Visual Studio 2022 includes a new editor font named <b>Cascadia</b>. <b>Cascadia</b> includes two variants: <b>Mono</b> and <b>Code</b>. <b>Mono</b> would give you the standardized look, whereas <b>Code</b> includes some hidden gems.

Take this Visual Basic code segment for example:

Imports System

Module Program

    Sub Main(args As String())

        Dim Age As String = 43

        If Age >= 40 AndAlso Age <= 50 Then

            Console.WriteLine("Age between 40 and 50")

        End If

    End Sub

End Module

If you run this code in VS Studio 2022, you will notice that it is easily legible and is quite easy on the eyes. However, compare it by running the same code but use the <b>Cascadia</b> font instead (following the instructions provided below).

Notice the ligatures in particular (this expresses two or more characters as a single unit). To change editor fonts, follow these steps:

  • Click Tools
  • Choose Options
  • In the left pane, select Fonts and Colors
  • Navigate to Cascadia Code
  • Click OK to change the font

Visual Studio Visual Basic Features

Read: Introduction to Blockchain Programming in Visual Basic

Inheritance Margin

The Inheritance margin</i adds icons to the left margin and shows where inheritance has taken place (.i.e., it shows where the code is derived from). To see this in action, add the following code inside a Visual Basic class:

Imports Microsoft.VisualBasic

Public Class Class1
    Public Overridable Sub Function1()

    End Sub

End Class

Public Class Class2
    Inherits Class1

    Public Overrides Sub Function1()
        MyBase.Function1()
    End Sub

End Class

You will notice four blue squares on the left margin:

Visual Studio Inheritance Margin Features

These indicators show where each class and function are derived from. To enable the Inheritance margin, follow these steps:

  • Click Tools
  • Choose Options
  • Expand Text Editor
  • Expand Basic
  • Select Advanced
  • Select Show inheritance margin
  • Click OK

VS Inheritance Margin

Subword Navigation

As .NET developers may know, most text editors allow you to navigate word by word. In Visual Studio, programmers could use Ctrl + Left or Ctrl + Right to navigate between words. Visual Studio 2022, however, includes subword navigation with which you can navigate through various parts of a word by using Ctrl + Alt + Left or Ctrl + Alt + Right. Attempt it with a variable name such as intMyAge or strMyName. As long as a word is comprised of a combination of words, this works perfectly.

Read: Making a Small Lotto Game in VB.NET

Preprocessor Symbols

Visual Studio 2022 now provides IntelliSense for Preprocessor Directives / Symbols.

Visual Studio Pre-processor Symbols

Visual Studio 2022 Allows Developer to Paste Code

In older versions of Visual Studio, when you pasted code into the editor, you would have to manually include the appropriate imports. Visual Studio 2022 allows you to paste code into the editor and it will add the necessary imports automatically. Consider the Visual Basic code below:

        Dim Age As String = 43

        If Age >= 40 AndAlso Age <= 50 Then

            Console.WriteLine("Age between 40 and 50")

        End If

If we were to paste this inside a Main method, the System import would be included automatically, and it would look like:

Imports System

Module Program

    Sub Main(args As String())

        Dim Age As String = 43

        If Age >= 40 AndAlso Age <= 50 Then

            Console.WriteLine("Age between 40 and 50")

        End If

    End Sub

End Module

Reassigned Variables in VB

The new underline reassigned feature is helpful when you want to know if a variable has been reassigned or not. Here is a small example:

    Sub Main(args As String())

        Dim Age As String = 43

        If Age >= 40 AndAlso Age <= 50 Then

            Console.WriteLine("Age between 40 and 50")

            Age = 50

        End If


    End Sub

In the above example, the variable Age is underlined. This is because it’s value has changed from 43 to 50. To enable this feature, follow these steps:

  • Click Tools
  • Click Options
  • Expand Text Editor
  • Expand Basic
  • Click Advanced
  • Click Underline reassigned variables
  • Choose OK

Read more Visual Basic and VB.NET programming tutorials with code examples.

Inline Parameter Changes

Inline parameter name hints display small indicators for parameter names. Here is an example of that in action:

Visual Studio Parameter Hints

In the above example, notice the ‘value:’ parameter in the WriteLine method of the Console object. This is quite handy because it will help – especially new developers – get to know the ins and outs of .NET

To enable this feature, follow these steps:

  • Click Tools
  • Click Options
  • Expand Text Editor
  • Expand Basic
  • Click Advanced
  • Select Display inline parameter name hints
  • Choose OK

Visual Studio Inline Parameter Name Hints

If you haven’t downloaded Visual Studio 2022, you can do so here. For more information on .NET 6, have a look here.

Read more .NET programming tutorials.

Hannes DuPreez
Hannes DuPreez
Ockert J. du Preez is a passionate coder and always willing to learn. He has written hundreds of developer articles over the years detailing his programming quests and adventures. He has written the following books: Visual Studio 2019 In-Depth (BpB Publications) JavaScript for Gurus (BpB Publications) He was the Technical Editor for Professional C++, 5th Edition (Wiley) He was a Microsoft Most Valuable Professional for .NET (2008–2017).

More by Author

Must Read