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

VB.NET Cheat Sheet

VB.NET Cheat Sheet

Core VB.NET syntax covering variables, control flow, classes and inheritance, collections, and common data types.

2 PagesBeginnerApr 5, 2026

Basics

Variables and console output.

vbnet
Module Program    Sub Main()        Dim name As String = "World"        Console.WriteLine($"Hello, {name}!")        Dim x As Integer = 42        Console.WriteLine("Value: " & x)    End SubEnd Module

Control Flow

Conditionals and loops.

vbnet
Dim x As Integer = 10If x > 5 Then    Console.WriteLine("big")ElseIf x = 5 Then    Console.WriteLine("equal")Else    Console.WriteLine("small")End IfFor i As Integer = 1 To 5    Console.WriteLine($"i = {i}")NextDim count As Integer = 0While count < 3    count += 1End While

Classes & Inheritance

Defining a base class and a derived class.

vbnet
Public Class Animal    Public Property Name As String    Public Sub New(name As String)        Me.Name = name    End Sub    Public Overridable Sub Speak()        Console.WriteLine($"{Name} makes a sound")    End SubEnd ClassPublic Class Dog    Inherits Animal    Public Sub New(name As String)        MyBase.New(name)    End Sub    Public Overrides Sub Speak()        Console.WriteLine($"{Name} barks")    End SubEnd Class

Collections

Generic collections and LINQ.

  • Dim list As New List(Of Integer)- Generic strongly-typed list
  • list.Add(5)- Appends an item to a collection
  • Dim dict As New Dictionary(Of String, Integer)- Key/value map
  • For Each item In list ... Next- Iterates a collection
  • Array.Sort(arr)- Sorts an array in place
  • list.Where(Function(x) x > 5)- LINQ filter (requires Imports System.Linq)

Data Types

Common built-in types.

  • Integer- 32-bit signed integer
  • Double- Double-precision floating point
  • String- Immutable text type
  • Boolean- True/False value
  • Nothing- Null reference / default value
  • Dim x As Integer?- Nullable value type
Pro Tip

Enable Option Strict On at the top of your files to catch implicit narrowing conversions at compile time instead of runtime InvalidCastExceptions.

Was this cheat sheet helpful?

Explore Topics

#VBNET#VBNETCheatSheet#Programming#Beginner#ControlFlow#ClassesInheritance#Collections#DataTypes#OOP#DataStructures#CheatSheet#SkillVeris
Advertisement
Sri Hayavadhana Info-Tech

Professional Web Designing Services

  • Responsive Websites
  • E-commerce Solutions
  • SEO Friendly Design
  • Fast & Secure
  • Support & Maintenance
Get a Free Quote

Share this Cheat Sheet