Visual Basic Sample Code
A practical collection of VB6 and VB.NET examples covering games, calculators, databases, graphics, multimedia, utilities, and business applications.
Quick Overview
Introduction
Why These Visual Basic Examples Matter
Visual Basic remains one of the most approachable ways to learn event-driven programming and rapid application development. These sample codes help you move beyond theory and learn by building practical software.
Whether you want to create educational apps, business tools, database utilities, games, graphics programs, or multimedia projects, these examples provide a strong reference point for your own assignments and applications.
Highlights
Why Learn Visual Basic?
Rapid Development
Build applications quickly with forms, controls, and event-driven programming.
Beginner Friendly
Excellent for learning programming fundamentals in a practical way.
Real Applications
Create calculators, database tools, business systems, and utilities.
Strong Legacy
Many businesses still rely on VB applications that need maintenance and extension.
Featured Book
Visual Basic Programming with Code Examples
by Dr. Liew Voon Kiong
A practical guide for beginners and intermediate developers to master Visual Basic programming, from classic VB6 to modern VB.NET, with real code examples and hands-on application building.
- Core concepts made easy
- Hands-on real-world applications
- 48 practical code examples
- VB6 and VB.NET side-by-side learning
New Release
VB.NET Game Programming for Beginners
Build fun 2D games with Visual Studio 2026 and Windows Forms
This beginner-friendly book shows readers how to create classic game projects while learning the essentials of Visual Basic, event-driven programming, graphics, animation, timers, collision detection, scoring systems, and interactive gameplay design.
- Step-by-step game building for beginners
- Fun 2D projects using VB.NET and Windows Forms
- Practical lessons in graphics, animation, and user input
- Ideal companion for the games and sample-code sections on VBTutor
VB.NET Windows Forms Projects Made Easy
Build 20 Practical Desktop Applications with Visual Studio 2026, .NET 10, and Step-by-Step VB.NET Programming
VB.NET Windows Forms Projects Made Easy is a hands-on programming guide for beginners, students, hobbyists, and aspiring developers who want to learn how to create real desktop applications using VB.NET, Windows Forms, Visual Studio 2026, and .NET 10.
- Calculator App
- Inventory Tracker
- Simple Point-of-Sale App
- Personal Expense Tracker
Featured Examples
Popular Sample Code
BMI Calculator
A simple Body Mass Index calculator using form controls, calculations, and conditional logic.
Private Sub CalculateBMI()
Dim height As Double
Dim weight As Double
Dim bmi As Double
height = Val(txtHeight.Text) / 100
weight = Val(txtWeight.Text)
If height > 0 Then
bmi = weight / (height * height)
lblBMI.Caption = Format(bmi, "0.00")
Else
MsgBox "Please enter valid height", vbExclamation
End If
End SubSimple Database Viewer
Connect to a database, retrieve records, and display results using ADO.
Private Sub LoadData()
Dim conn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim sql As String
Set conn = New ADODB.Connection
conn.Open
sql = "SELECT * FROM Customers"
End SubSummary
Why Visual Basic Still Matters
- Legacy maintenance: Many businesses still depend on VB6 solutions.
- Rapid prototyping: Ideal for quickly building internal tools and proof-of-concepts.
- Teaching value: Great for learning programming logic and event-driven design.
- Windows integration: Works naturally with desktop workflows and Office-related automation.
- Practicality: Useful for students, hobbyists, and business applications.
Practice
Suggested Exercises
Exercise 1: Temperature Converter
Create a program that converts between Celsius and Fahrenheit with automatic updates and clear UI feedback.
Exercise 2: Contact Manager
Create a simple contact management system with add, search, save, and load features.
About
About Dr. Liew Voon Kiong
Dr. Liew Voon Kiong is the founder of VBTutor.net and a long-time educator, author, and programmer. His tutorials and books have helped millions of learners understand Visual Basic in a practical and approachable way.
More Resources
Continue Learning
VB Game Programming Book
Learn to build fun 2D games with Visual Studio 2026 and Windows Forms.
View Book