XCODX |

Visual Basic Online Compiler & Interpreter

Select Language
Online Code Compiler
Full HTML IDE
Py main.py
Program Output Ready
  Welcome to XCODX Online Compiler

  Quick Start:
  Ctrl+Enter  Run code
  Ctrl+S      Save / Download
  Ctrl+L      Clear output

  Select a language and start coding.
Success
Operation completed

About Visual Basic

VB.NET is Microsoft's modernization of Visual Basic: the beginner-friendly, English-like syntax of classic VB rebuilt on the Common Language Runtime with full object orientation, generics, LINQ, and access to the entire .NET class library. It remains widely used in enterprise line-of-business applications, Office automation shops, and introductory programming courses across US and UK schools, where Dim, Sub, and For...Next read almost like plain sentences. This variant of the page runs your code on the Mono-based VB compiler, which is well suited to console exercises. The terminal is interactive, so Console.ReadLine genuinely pauses your running program and picks up whatever you type, no Visual Studio installation required.

Hello World in Visual Basic

Module Program
    Function Factorial(ByVal n As Integer) As Long
        If n <= 1 Then Return 1
        Return n * Factorial(n - 1)
    End Function

    Sub Main()
        Console.Write("Enter your name: ")
        Dim name As String = Console.ReadLine()
        Console.WriteLine("Hello, " & name & "!")

        Console.Write("Enter a number: ")
        Dim n As Integer = Integer.Parse(Console.ReadLine())
        Console.WriteLine(n & "! = " & Factorial(n))

        For i As Integer = 1 To 3
            Console.WriteLine("Loop pass " & i)
        Next
    End Sub
End Module

When to use Visual Basic

VB.NET remains a staple of introductory programming units in UK GCSE/A-level and US community college curricula, where readable keywords lower the barrier for first algorithms: loops, string handling, and simple console menus. In industry it powers long-lived internal business applications, reporting tools, and Office-adjacent automation that teams still extend today. Developers maintaining that legacy code use this page to isolate a function and test it quickly, and students converting between VB.NET and C# check semantics side by side without spinning up an IDE.

Common questions

Does Console.ReadLine work interactively on this page?

Yes. Your compiled program runs attached to a real terminal, so Console.ReadLine blocks until you type a line and press Enter, and Console.Write prompts appear immediately beforehand. Multi-question programs, input validation loops, and simple text menus behave exactly as they would in a local command window.

What compiles my VB.NET code in this variant?

This page uses the Mono project's VB.NET compiler and runtime, which implements the language and the core class libraries used in console programs: Console, String, Math, collections, and file-free utility types. If you specifically want the modern .NET runtime with the Roslyn-era toolchain, use the separate VB.NET (.NET runtime) page.

Can I build Windows Forms or use NuGet packages here?

No. The sandbox compiles a single console source file, so graphical frameworks like Windows Forms and WPF, project files, and NuGet dependencies are out of scope. Everything in the core library that console programs rely on is available, which covers classwork, algorithm practice, and testing business logic extracted from larger applications.

How do I read a number from the user in VB.NET?

Console.ReadLine always returns a String, so convert it: Integer.Parse for whole numbers, Double.Parse for decimals, or the CInt and CDbl conversion functions. The example uses Integer.Parse(Console.ReadLine()). Wrap the parse in a loop if you want to reject bad entries, since Parse throws on text that is not a number.

Why does my program need a Module and Sub Main?

A VB.NET console program starts at Sub Main, and the example wraps it in a Module — a container for code that needs no object instance. Put your entry logic in Sub Main() ... End Sub inside Module Program, define helper Functions and Subs alongside it, and execution begins automatically at Main.

Is VB.NET case-sensitive, and do statements end with semicolons?

No on both counts — VB.NET keywords and identifiers are case-insensitive, so Dim, dim, and DIM mean the same thing, and a statement ends at the line break rather than a semicolon. This readable, English-like style, where a long line is continued with an underscore, is why courses often teach first algorithms in it.

How Visual Basic runs on XCODX

Sandbox filename
main.bas
Entry point
single main source file
Editor grammar
vb
Reading stdin
INPUT
Input delivery
live WebSocket stream
Prompt flushing
flush manually before reading input
Compile limit
10 s
Run limit
3 s batch · up to 3 min live
Memory
256 MB per stage
Max source
50,000 characters

Default program on this page

Imports System

Module Program
    Sub Main()
        Console.WriteLine("Hello from VB.NET!")
    End Sub
End Module