VB.NET interview questions and answers for Visual Basic developers

VB.NET interview questions test whether you know the Visual Basic language on .NET well enough to maintain and improve real business code: Option Strict, ByVal and ByRef, how Nothing behaves, AndAlso versus And, CType versus DirectCast, events with WithEvents and Handles, and structured error handling. Most VB.NET roles involve existing WinForms, Web Forms or back-office applications, so expect code-reading questions and migration scenarios alongside the language basics.

By Published 8 min read

Where VB.NET questions come up

VB.NET is asked about mostly in roles that keep established systems running: internal line-of-business apps, WinForms desktop tools, ASP.NET Web Forms sites, reporting and Office integrations in finance, insurance, manufacturing and government. RPA teams also meet it, because UiPath workflows can use VB.NET expressions, which is covered in UiPath interview questions. Interviewers rarely ask for clever algorithms. They want to know you can read a decade-old module, spot a late-binding bug and change it safely. Microsoft has said it keeps supporting Visual Basic on modern .NET while not planning to evolve the language at C#'s pace, so expect questions on how you would modernize a VB codebase.

  1. Language screenKeywords and behavior that differ from C#: options, operators, Nothing, arrays and conversions.
  2. Code readingA short VB routine with a hidden bug, such as a non-short-circuit And or a ByRef side effect, read aloud.
  3. Framework questionsWinForms events and threading, ADO.NET data access, configuration, often in the .NET Framework flavor the team runs.
  4. Maintenance and migrationHow you would test, refactor or port an old application without breaking the business process it supports.

VB.NET fundamentals questions

Language basics for freshers and every first round
QuestionWhat it testsWhat a strong answer shows
What do Option Strict, Option Explicit and Option Infer do?Compiler optionsExplicit requires every variable to be declared. Strict forbids implicit narrowing conversions and late binding. Infer lets Dim x = 5 take its type from the value. Strict On should be the project default.
ByVal versus ByRef?Parameter passingByVal (the default) passes a copy of the value, or of the reference for objects. ByRef passes the variable itself, so the method can replace what the caller holds.
What does Nothing mean for a value type?DefaultsAssigning Nothing to an Integer gives 0, its default value, not null. Use Integer? (Nullable(Of Integer)) when you need a missing value.
What is the difference between / and \?Operators/ always returns a floating result. \ is integer division and drops the remainder. Mod gives the remainder.
And versus AndAlso, Or versus OrElse?Short-circuitingAnd and Or always evaluate both sides. AndAlso and OrElse stop when the result is known, which matters for null checks and expensive calls.
If operator versus IIf function?EvaluationIIf is a function, so both branches run before it is called, and it returns Object. The If(condition, a, b) operator evaluates only the needed branch and is typed.
What does Dim items(4) As String create?ArraysFive elements, indexes 0 to 4. VB declares the upper bound, not the length, which trips up developers coming from C#.
What is a Module?Program structureA container whose members are all shared and accessible without a qualifier. It compiles to a sealed class with static members and cannot be instantiated.
Is VB.NET case-sensitive?SyntaxIdentifiers and keywords are not. String comparisons depend on Option Compare (Binary by default, or Text) or the comparison you pass explicitly.
Structure versus Class?Type systemA Structure is a value type copied on assignment; a Class is a reference type. Keep structures small and immutable.
What is Friend access?VisibilityVisible inside the same assembly, the equivalent of C# internal. Protected Friend adds derived classes in other assemblies.
Language basics for freshers and every first round. Scroll sideways on a small screen.
Option Strict On
Option Explicit On

Module Basics
    Function Check(label As String, result As Boolean) As Boolean
        Console.WriteLine(label & " ran")
        Return result
    End Function

    Sub Bump(ByVal a As Integer, ByRef b As Integer)
        a += 1
        b += 1
    End Sub

    Sub Main()
        Console.WriteLine(7 / 2)     ' 3.5: / always gives a Double
        Console.WriteLine(7 \ 2)     ' 3: \ is integer division
        Console.WriteLine(7 Mod 2)   ' 1

        Dim n As Integer = Nothing   ' a value type gets its default, 0
        Console.WriteLine(n)

        Dim x As Integer = 1
        Dim y As Integer = 1
        Bump(x, y)
        Console.WriteLine(x & " " & y)   ' 1 2

        ' And evaluates both sides; AndAlso stops at the first False.
        If Check("And left", False) And Check("And right", True) Then Console.WriteLine("never")
        If Check("AndAlso left", False) AndAlso Check("AndAlso right", True) Then Console.WriteLine("never")

        Dim s As String = Nothing
        Console.WriteLine(If(s Is Nothing, 0, s.Length))   ' 0: only one branch runs
        Try
            Console.WriteLine(CInt(IIf(s Is Nothing, 0, s.Length)))
        Catch ex As NullReferenceException
            Console.WriteLine("IIf evaluated s.Length anyway")
        End Try
    End Sub
End Module
Operators, ByRef and short-circuiting in one console program. Output in the comments was checked by compiling and running it.

Conversions, types and late binding

  • CType, DirectCast or TryCast? CType converts and can call conversion operators or parse a string into a number. DirectCast only succeeds when the object already is that type, and is a little faster. TryCast returns Nothing instead of throwing and works only with reference types.
  • What does `CInt(2.5)` return? 2. CInt rounds half to even (banker's rounding), so CInt(3.5) is 4. Use Math.Round with a MidpointRounding option, or Math.Floor, when the business rule says otherwise.
  • CInt, Integer.Parse or Integer.TryParse for user input? TryParse, because it reports failure without an exception. CInt accepts more formats and throws on bad input, which is fine for values you already trust.
  • What is late binding, and why does Option Strict block it? Calling members on a variable typed Object, resolved at run time through reflection. It is slow, hides typos until the line runs, and breaks refactoring tools. It was common when automating Office through COM.
  • `=` or `Is` for comparing objects? Is checks whether two references point to the same object, and IsNot the opposite. = compares values and needs an operator or Equals implementation.
  • How do you build a large string in a loop? With System.Text.StringBuilder. Repeated & creates a new string each time because strings are immutable.
Option Strict On

Public Class Downloader
    Public Event Finished(fileName As String)
    Public Sub Run(fileName As String)
        RaiseEvent Finished(fileName)
    End Sub
End Class

Module Casts
    Private WithEvents worker As New Downloader()

    Private Sub OnFinished(fileName As String) Handles worker.Finished
        Console.WriteLine("finished " & fileName)
    End Sub

    Sub Main()
        Dim boxed As Object = "42"
        Console.WriteLine(CInt(boxed) + 1)                      ' 43: CInt converts the string
        Console.WriteLine(TryCast(boxed, String) IsNot Nothing) ' True
        Try
            Dim n As Integer = DirectCast(boxed, Integer)       ' a String is not an Integer
        Catch ex As InvalidCastException
            Console.WriteLine("DirectCast needs the real runtime type")
        End Try

        Dim scores(2) As Integer          ' upper bound 2: three elements
        Console.WriteLine(scores.Length)  ' 3

        worker.Run("report.csv")
    End Sub
End Module
Conversions, array bounds and declarative events. WithEvents plus Handles wires the handler at compile time; AddHandler does the same at run time.

Object-oriented and event questions

Intermediate questions
QuestionWhat it testsWhat a strong answer shows
Handles versus AddHandler?EventsHandles with a WithEvents field connects a handler declaratively. AddHandler and RemoveHandler connect and disconnect at run time, for objects created dynamically. Forgetting RemoveHandler keeps the subscriber alive.
MustInherit, MustOverride, Overridable and NotOverridable?InheritanceAbstract class, abstract member, virtual member, and a sealed override. Members are not overridable unless marked Overridable.
Overrides versus Shadows?Member hidingOverrides replaces a virtual member polymorphically. Shadows hides the base member by name, so a call through a base-typed variable still runs the base version, which surprises people.
What is the My namespace?VB featuresShortcuts such as My.Settings, My.Computer.FileSystem and My.Application. Handy, but check that the project type supports them before relying on them in a library.
Why do WinForms projects use partial classes?Designer codeThe designer writes control setup into a separate partial file, so your code and generated code live in one class without overwriting each other.
How do you update a WinForms control from a background thread?ThreadingMarshal back to the UI thread with Control.Invoke or BeginInvoke (checking InvokeRequired), or use Async and Await so the continuation returns to the UI context.
Shared members in a class versus a Module?DesignBoth are static. A class with Shared members needs qualification and can mix in instance members; a Module's members are global, which is convenient but makes name clashes and hidden coupling easier.
What is an Interface in VB, and how is it implemented?ContractsDeclared with Interface and implemented with an Implements clause on the class and on each member, which lets a member have a different name from the interface member.
Intermediate questions. Scroll sideways on a small screen.

Error handling, LINQ and async questions

  • Try/Catch or On Error GoTo? Use Try, Catch and Finally. On Error is kept for VB6 compatibility; it makes control flow hard to follow and cannot be mixed with Try in the same method.
  • What is a Catch ... When filter? A condition evaluated before the Catch block is chosen. VB has supported exception filters since its first .NET version, long before C# added them. They are good for retry rules and for logging without unwinding the stack.
  • What does the Using statement guarantee? That Dispose is called on the object when the block ends, even after an exception. Use it for connections, readers, files and streams.
  • Write a LINQ query in VB query syntax. From o In orders Where o.Total > 100 Order By o.Total Descending Select o. VB also has the Aggregate keyword, for example Aggregate o In orders Into Sum(o).
  • What are XML literals? A VB-only feature where XML can be written inline in code and queried with axis properties. Useful in old integration code, and worth recognizing even if you do not write new code with it.
  • What does Async and Await change in a WinForms button handler? The handler returns to the message loop while the awaited work runs, so the window stays responsive. Use Async Sub only for event handlers and Async Function ... As Task elsewhere.
Option Strict On
Imports System.Linq

Module Filters
    Function Load(attempt As Integer) As String
        Throw New TimeoutException("attempt " & attempt.ToString())
    End Function

    Sub Main()
        Console.WriteLine(CInt(2.5) & " " & CInt(3.5) & " " & CInt(-2.5))  ' 2 4 -2

        Dim maybe As Integer? = Nothing
        Console.WriteLine(maybe.HasValue & " " & maybe.GetValueOrDefault()) ' False 0

        For attempt As Integer = 1 To 3
            Try
                Load(attempt)
            Catch ex As TimeoutException When attempt < 3
                Console.WriteLine("retrying after " & ex.Message)
            Catch ex As TimeoutException
                Console.WriteLine("giving up after " & ex.Message)
            End Try
        Next

        Dim orders = {120D, 75D, 300D, 40D}
        Dim big = From o In orders Where o >= 100D Order By o Descending Select o
        Console.WriteLine(String.Join(",", big))          ' 300,120
        Console.WriteLine(Aggregate o In orders Into Sum(o)) ' 535
    End Sub
End Module
Rounding, nullable values, an exception filter for retries, and VB query syntax. Compiled and run; outputs are in the comments.

Senior and migration scenarios

Scenarios for experienced VB.NET developers
ScenarioWhat the interviewer wants to hearPitfalls to name
An old project has Option Strict Off everywhere. You are asked to turn it on.Turn it on file by file with Option Strict On at the top, fix narrowing conversions with explicit casts, replace late-bound calls with typed references, and keep tests green at each step.Silent behavior changes when an implicit conversion becomes an explicit one with different rounding.
Port a VB6 application.Inventory forms, COM dependencies and data access first, then decide between an assisted upgrade and a rewrite of the risky parts, with the old app as the reference for expected results.Variant, default properties, 1-based collections, fixed-length strings and On Error flow.
Move a .NET Framework VB app to modern .NET.Check which app models exist there: WinForms and class libraries can move, ASP.NET Web Forms cannot and needs a new web layer. Use the upgrade tooling as a starting point and compare outputs.Configuration, the My namespace and third-party controls that only target Framework.
The team wants new code in C#.One language per project, both compile to the same IL, so VB and C# projects in one solution reference each other freely. Move by project, not by file.Mismatched naming because VB is case-insensitive, and two styles of error handling living side by side.
A WinForms app slowly uses more memory over a day.Look for event handlers added with AddHandler and never removed, undisposed GDI objects and connections, and static collections that only grow.Assuming the garbage collector frees objects that are still referenced by an event.
A report routine is very slow.Profile first. Common causes are string concatenation in loops, a database query per row, late binding in a hot loop, and DataSet use where a reader would do.Optimizing before measuring, or rewriting the whole routine at once.
Scenarios for experienced VB.NET developers. Scroll sideways on a small screen.

Fictional example

Answering "What does this condition do wrong?"
Interviewer
This line throws a NullReferenceException in production: If customer IsNot Nothing And customer.Orders.Count > 0 Then. Why, and how would you fix it?
Candidate
And is not short-circuiting in VB, so when customer is Nothing the right side still runs and customer.Orders fails. The fix is AndAlso, which skips the second check when the first is False. I would also search the codebase for the same pattern, since a team that wrote this once probably wrote it in other places, and I would add a test with a missing customer so it cannot come back quietly. If the project still has Option Strict Off, I would note that as the next thing to tighten, because it hides similar run-time surprises.

How to prepare for a VB.NET interview

  • Days 1 and 2: write small console programs for each fundamentals question above and predict the output before running them.
  • Day 3: conversions and Option Strict. Turn it on in an old sample, fix every error and note which fixes changed behavior.
  • Day 4: events and WinForms threading. Build a form that runs a slow task with Async and Await, then break it with a cross-thread update and fix it.
  • Day 5: data access with ADO.NET and LINQ in VB syntax; read ADO.NET interview questions for the data-layer topics.
  • Days 6 and 7: rehearse one migration story and one debugging story from your own work, with what you measured before and after.

For the runtime and web side, read .NET interview questions; if the team also writes C#, C# interview questions covers the same platform from the other language.

Code-reading rounds go well when you explain the bug, the fix and the test in that order, and that order is easy to lose under questioning. Natively, an AI interview assistant for Mac and Windows, can transcribe a mock VB.NET round on your computer so you can review how you explained a fix afterward. During practice it can read a screenshot of a VB routine or a compiler error and suggest what to look at, and with Pro or the free trial it can use the résumé and job description you add. The transcript and notes remain there for review.

Questions people ask

What VB.NET questions are asked in interviews?

Option Strict and Explicit, ByVal versus ByRef, Nothing for value types, And versus AndAlso, If versus IIf, CType, DirectCast and TryCast, Modules and Shared members, WithEvents and Handles, Try and Catch with When filters, and migration scenarios.

What is the difference between And and AndAlso in VB.NET?

And always evaluates both operands. AndAlso stops when the first operand is False, so it is the one to use for null checks and for skipping expensive calls.

What is the difference between CType and DirectCast?

CType converts between types and can parse or call conversion operators. DirectCast only works when the object already is the target type and throws InvalidCastException otherwise. TryCast returns Nothing instead of throwing.

Is VB.NET still used, and is it worth preparing for?

Many business applications are still written and maintained in VB.NET, especially WinForms and older web apps. Interviews for those teams focus on reading existing code and modernizing it safely.

Where to go next

Practice with the same assistant you would use on a call: it listens, transcribes and suggests answers from your own resume and the job description.

Facts on this page were last checked on . Product details come from the Natively app itself; if something here is out of date, tell us at hello@heynatively.com.

Keep reading

Put it on your own machine.

A live-conversation assistant that runs locally. Your conversations stay on your machine.

macOS 12+ · Windows 10/11

© 2026 Natively AI Private Limited

Source-available under the Natively Personal Use Source License v1.0 · IP geolocation by DB-IP