VB.NET
Module Program
    Sub Main()
        Console.WriteLine("Welcome to Online IDE!")
        Console.WriteLine("Start coding in VB.NET...")
    End Sub
End Module

Press Run or Ctrl ↵ to execute main.vb.
Type program input here while it runs.

VB.NET

Online VB.NET Compiler

Your code is compiled with vbc (Visual Basic 16.9) and runs on .NET 10, starting from Sub Main. Console.ReadLine() waits for you to type in the terminal.

Try it above

How VB.NET runs here

Versions
Visual Basic 16.9 on .NET 10
Build
vbc *.vb
Run
dotnet main.dll
Limits per run
512 MB memory, 15 s of CPU time on half a core, 2 MB of output
Time
Up to 10 minutes a run (30 on a paid plan); waits 2 minutes for input (5 on a paid plan)
Sandbox
Each run gets its own Linux sandbox with no network access. Text files your program writes next to your code open as new tabs.

A VB.NET program that reads input

This main.vb reads numbers into a List(Of Integer) and uses LINQ for the sum and average:

VB.NET
Module Program
    Sub Main()
        Console.Write("How many numbers? ")
        Dim n As Integer = Integer.Parse(Console.ReadLine())
        Dim nums As New List(Of Integer)
        For i As Integer = 1 To n
            Console.Write($"Number {i}: ")
            nums.Add(Integer.Parse(Console.ReadLine()))
        Next
        nums.Sort()
        Console.WriteLine("Sorted: " & String.Join(" ", nums))
        Console.WriteLine($"Sum: {nums.Sum()}, average: {nums.Average():F2}")
    End Sub
End Module
Terminal
$ vbc *.vb && dotnet main.dll
How many numbers? 4
Number 1: 12
Number 2: 7
Number 3: 30
Number 4: 5
Sorted: 5 7 12 30
Sum: 54, average: 13.50

Reading input in VB.NET

  • Console.ReadLine() returns the line as a String. Integer.Parse() converts it and throws FormatException on bad input; Integer.TryParse(text, n) returns False instead, so you can ask again.
  • Option Strict is Off here, as in a new console project, so Dim n As Integer = Console.ReadLine() compiles. Bad input then fails at run time with an InvalidCastException.
  • For several numbers on one line: Console.ReadLine().Split(" "c).Select(Function(s) Integer.Parse(s)).ToList().

What isn’t available here

  • Windows Forms and WPF, so MsgBox, InputBox and forms don’t work. Use Console.WriteLine and Console.ReadLine.
  • NuGet packages. The .NET 10 base library is referenced, with System, System.Linq and System.Collections.Generic imported for you.
  • My.Computer and My.Application. The My namespace has no application services here.

Every .vb file is compiled together, so a class or module in a second file is available in main.vb.

Errors you’ll see

  • “'total' is not declared. It may be inaccessible due to its protection level.” (BC30451) Option Explicit is On, so declare variables with Dim.
  • “Conversion from string "abc" to type 'Integer' is not valid.” Text assigned to an Integer under Option Strict Off. Use Integer.TryParse.
  • A FormatException from Integer.Parse: the input wasn’t a whole number, or had two numbers on one line.

Questions

Which Visual Basic version does this use?

Visual Basic 16.9, compiled with vbc and run on .NET 10.

Can I use MsgBox or Windows Forms?

No. They need Windows and a screen. The program runs in a Linux terminal, so use Console.WriteLine and Console.ReadLine.

How do I read a number in VB.NET?

Dim n As Integer = Integer.Parse(Console.ReadLine()). Type the number in the terminal while the program runs.