Visual Basic 6 Cheat Sheet
Classic VB6 syntax including variable declarations, conditionals, loops, and procedures for legacy Windows desktop applications.
1 PageBeginnerApr 12, 2026
Variables & Constants
Declaring typed variables and constants.
vb
Dim strName As StringDim intCount As IntegerDim dblPrice As DoubleDim blnActive As BooleanConst MAX_VALUE As Integer = 100strName = "World"MsgBox "Hello, " & strName & "!"
Control Flow
If statements and Select Case.
vb
If x > 0 Then MsgBox "Positive"ElseIf x < 0 Then MsgBox "Negative"Else MsgBox "Zero"End IfSelect Case grade Case "A" MsgBox "Excellent" Case "B", "C" MsgBox "Good" Case Else MsgBox "Needs improvement"End Select
Loops
For, Do While, and Do Until loops.
vb
For i = 1 To 10 Debug.Print iNext iFor i = 10 To 1 Step -1 Debug.Print iNext iDo While x < 10 x = x + 1LoopDo Until x = 0 x = x - 1Loop
Subs, Functions & Arrays
Reusable procedures and array declarations.
vb
Sub Greet(name As String) MsgBox "Hello, " & nameEnd SubFunction Square(x As Double) As Double Square = x * xEnd FunctionDim arr(1 To 5) As IntegerDim dynArr() As StringReDim dynArr(10)ReDim Preserve dynArr(20)
Pro Tip
Put `Option Explicit` at the top of every module — without it VB6 silently creates a new Variant variable on any misspelled name, which is one of the most common sources of hard-to-find bugs in legacy VB6 code.
Was this cheat sheet helpful?
Explore Topics
#VisualBasic6#VisualBasic6CheatSheet#Programming#Beginner#VariablesConstants#ControlFlow#Loops#SubsFunctionsArrays#CheatSheet#SkillVeris
Advertisement
Sri Hayavadhana Info-Tech
Professional Web Designing Services
- Responsive Websites
- E-commerce Solutions
- SEO Friendly Design
- Fast & Secure
- Support & Maintenance