100% Free Forever
AI-Powered Learning
Industry Expert Content
Certificates & Badges
Learn At Your Own Pace
Programming

VB.NET Quick Reference

A condensed reference for VB.NET syntax covering data types, control flow, collections, LINQ, and object-oriented constructs.

PracticeBeginner7 min readJul 10, 2026
Analogies

VB.NET at a Glance

This quick reference assumes Option Strict On and Option Explicit On as the baseline for any VB.NET code sample below, both should be the default for real projects. Use it as a fast lookup for syntax you don't type often enough to remember cold: declaring collections, LINQ query syntax, or the exact keyword for implementing an interface. Where VB.NET syntax differs meaningfully from C#, that's called out, since many developers using this reference are translating knowledge from one language to the other.

🏏

Cricket analogy: It's like a fielding captain keeping a laminated card of DRS review rules in his pocket for the rare moment he needs to double-check a review window rather than memorizing the fine print, a quick reference serves the same purpose for syntax you don't type daily.

Data Types and Declarations

VB.NET's core value types are Integer, 32-bit, Long, 64-bit, Double and Single, floating point, Decimal, 128-bit, ideal for currency because it avoids binary floating-point rounding error, Boolean, and Date, which stores both date and time. Reference types include String, immutable, like in C#, arrays, Dim numbers(4) As Integer creates a 5-element array, since VB.NET array bounds are inclusive of the upper index, and any Class you define. Declare variables with Dim, constants with Const, and use Nullable(Of T), or the shorthand Integer?, when a value type needs to represent 'no value' distinctly from its default, 0, False, or #1/1/0001#.

🏏

Cricket analogy: It's like distinguishing a player's exact batting average, a precise Decimal-style figure that matters for records, from a rough estimate rounded to the nearest five, using Decimal instead of Double for money is choosing precision where precision actually matters, the same way official cricket statistics never get casually rounded.

Control Flow Constructs

Conditional branching uses If...Then...ElseIf...Else...End If for general logic, or Select Case for matching a single expression against several discrete values or ranges, Case 1 To 5, Case Is > 100, Case Else. Looping constructs include For...Next for counted loops, For Each...Next for iterating any IEnumerable, a List(Of T), an array, a Dictionary's collection of key-value pairs, and Do While...Loop or Do...Loop Until for condition-driven repetition where the exact number of iterations isn't known upfront. Exit For, Exit Do, and Exit Sub/Function break out of the current loop or procedure early, while Continue For and Continue Do skip to the next iteration without exiting entirely.

🏏

Cricket analogy: It's like a captain's fielding plan branching on the batter, a Select Case-style decision tree with distinct field settings for a left-hander, a right-hander smashing sixes, or a tail-ender defending, rather than one generic If statement covering every situation clumsily.

Collections and LINQ

List(Of T) is the general-purpose resizable collection for most scenarios, offering .Add, .Remove, .Contains, and index-based access; Dictionary(Of TKey, TValue) provides fast key-based lookup, dict("abc123") retrieves a value in near-constant time versus scanning a List. LINQ can be written in query syntax, which reads close to SQL, Dim result = From c In customers Where c.IsActive Select c.Name Order By c.Name, or in method syntax using lambda expressions, customers.Where(Function(c) c.IsActive).Select(Function(c) c.Name).OrderBy(Function(c) c.Name). Both compile to the same underlying method calls; query syntax tends to read more naturally for multi-clause filtering and joins, while method syntax composes more easily when chaining a small number of operations.

🏏

Cricket analogy: It's like choosing between scanning an entire scorecard by eye for a specific player's runs, a List's linear scan, versus looking the player up directly in an indexed stats database by name, a Dictionary's near-instant key lookup.

OOP Syntax Essentials

A class is declared with Public Class Name...End Class, with properties defined via Public Property Name As Type, auto-implemented, or with explicit Get/Set accessors when validation logic is needed. Inherits establishes a base class relationship, a class can inherit from only one base class; Implements fulfills one or more interface contracts, a class can implement multiple interfaces. A constructor is Public Sub New(...), VB.NET has no separate 'constructor' keyword, New is simply a specially named Sub. Access modifiers, Public, Private, Protected, Friend, and Protected Friend, control visibility exactly as their C# counterparts do, with Friend meaning 'visible within the same assembly,' VB.NET's equivalent of C#'s internal.

🏏

Cricket analogy: It's like a franchise's constitution allowing a team to have exactly one head coach, Inherits, single base class, but sign multiple specialist consultants, a batting coach, a fielding coach, a fitness consultant, each fulfilling a distinct contract, Implements, multiple interfaces.

vbnet
Public Interface IReportable
    Function ToReportLine() As String
End Interface

Public Class Product
    Implements IReportable

    Public Property Name As String
    Public Property Price As Decimal

    Public Sub New(name As String, price As Decimal)
        Me.Name = name
        Me.Price = price
    End Sub

    Public Function ToReportLine() As String Implements IReportable.ToReportLine
        Return $"{Name}: {Price:C}"
    End Function
End Class

Module Program
    Sub Main()
        Dim products As New List(Of Product) From {
            New Product("Widget", 9.99D),
            New Product("Gadget", 24.5D),
            New Product("Gizmo", 3.75D)
        }

        Dim expensive = From p In products
                        Where p.Price > 5D
                        Order By p.Price Descending
                        Select p

        For Each item In expensive
            Console.WriteLine(item.ToReportLine())
        Next
    End Sub
End Module

This reference assumes Option Strict On and Option Explicit On throughout. Without them, several of these examples, like implicit type conversions in LINQ projections, would compile but could behave unpredictably at runtime.

  • Use Decimal for currency, Integer/Long for whole numbers, and Date for combined date-and-time values.
  • Select Case is cleaner than nested If-ElseIf chains when matching one expression against several discrete values or ranges.
  • For Each works over any IEnumerable; Do While/Do Until handle condition-driven loops where the iteration count isn't fixed.
  • List(Of T) suits general sequential storage; Dictionary(Of TKey, TValue) gives near-constant-time key-based lookup.
  • LINQ query syntax (From...Where...Select) and method syntax (.Where().Select()) compile to the same calls, pick whichever reads more clearly for the operation.
  • A class Inherits at most one base class but can Implements multiple interfaces.
  • Friend visibility means 'accessible within the same assembly,' VB.NET's equivalent of C#'s internal.

Practice what you learned

Was this page helpful?

Topics covered

#Programming#VBNETStudyNotes#VBNETQuickReference#NET#Quick#Reference#Glance#StudyNotes#SkillVeris#ExamPrep