Keywords In Visual Basic Are Words That
Keywords in Visual Basic are words with predefined meanings in the language. They form declarations, conditions, loops and other parts of a program's syntax. For example, Dim declares a variable and If introduces a condition. Many keywords are reserved, so using them as names requires.
Which licences fit your PC setup?
Prices are an AUD snapshot, not a live quote. Confirm variant and total on the listing.
-

Server 2022 RDS User CAL
$133.00 AUD
-

Office 2021 Pro Plus key
$57.00 AUD
-

SQL Server 2022 Standard
$399.99 AUD
How keywords differ from names you choose
A keyword belongs to the language; an identifier is a name you give to something in your program. In the statement “Dim customerName As String”, Dim introduces the variable declaration, As introduces its type, and String identifies the built-in text data type. The identifier customerName is your choice.
You could rename customerName to contactName without changing the declaration's structure. Replacing Dim with an invented word would not create an equivalent declaration. The compiler recognises language syntax, rather than interpreting ordinary English instructions. Microsoft's Dim statement reference explains the declaration's parts.
Visual Basic keywords are case-insensitive: Dim, DIM and dim have the same meaning. Consistent capitalisation still helps readers recognise familiar patterns. Changing the case of a reserved word does not make it available as an ordinary variable name.
The examples here refer to Visual Basic for .NET. When following older tutorials, check which language environment they describe before copying syntax into your project.
Common keyword groups and their purposes
Learn keywords through the tasks they perform. A declaration creates a named program element, while a control statement determines which instructions run. Recognising these roles makes an unfamiliar procedure easier to read.
Declaring variables, procedures and types
- Dim declares a variable. As can specify its data type, such as Integer, String or Boolean.
- Const declares a constant: a named value that cannot be reassigned during execution.
- Sub declares a procedure that does not return a value to its caller.
- Function declares a procedure that returns a value. Return can supply that value and leave the procedure.
- Class introduces a class declaration. Inherits specifies a base class from which a class derives.
For example, “Dim isReady As Boolean = False” declares a variable named isReady and gives it an initial value. Dim, As, Boolean and False are language keywords; isReady is the identifier. False is a Boolean value, rather than the text string “False”.
Making decisions and repeating actions
Control flow keywords determine which path execution follows. Microsoft's control flow guide groups these structures into decisions, loops and other control structures.
- If, Then, ElseIf and Else express conditional branches. A multiline If block closes with End If.
- Select Case groups alternatives around a test expression, with Case clauses describing the alternatives.
- For and Next form a counter-based loop; For Each and Next iterate through a collection.
- While and End While repeat a block while a condition remains true.
- Do and Loop form another loop structure, with While or Until supplying a condition where required.
- Exit leaves a supported enclosing construct, as in Exit For. It must be used with the appropriate construct name.
These words work together as syntax. Loop alone does not define a complete loop, and End If is the closing statement for a multiline If block. Learn the surrounding structure alongside each individual keyword.
Controlling access to program elements
Access modifiers specify which code can use a declared element. Public allows broad access, subject to the accessibility of its containing element. Private restricts access to the declaring type or module, including code within contained types. Protected permits access within the declaring class and derived classes; Friend permits access within the same assembly.
Choose access deliberately: a helper procedure used only inside a class usually does not need to be Public. Microsoft's access levels reference explains the restrictions and combinations. These modifiers organise access between code elements; they do not replace checks on user permissions.
Reserved keywords and names in square brackets
Visual Basic distinguishes reserved keywords from unreserved keywords. Reserved words have restrictions on their use as identifiers. Unreserved words, such as Where, can serve as names, although choosing them may make code harder to follow. Microsoft's keyword reference lists both groups.
Square brackets allow a reserved word to be used as an identifier. For example, “Dim [Class] As String” declares a variable whose name is Class. The brackets tell the compiler to interpret that occurrence as a name. This does not redefine the Class keyword.
Prefer a descriptive name such as className when you control the naming. Brackets are useful when working with existing names that conflict with the language. Microsoft's guidance on keywords as element names explains this escape mechanism.
Recognising keywords in form code
Not every familiar word in a Visual Basic statement is a keyword. In a Windows Forms application, TextBox1.Clear() calls a control's method. Clear is a method name here. The Sub and End Sub statements surrounding its event handler are language syntax.
The guide to coding a clear button in Visual Basic provides a practical setting for spotting that distinction. Separate the words that structure the procedure from the control names and methods used inside it.
Likewise, a checkbox condition can use If and Then to decide what happens when its Checked property is true. Checked is a property name; If and Then are keywords. Practise identifying those roles while coding a checkbox in Visual Basic.
Check keyword syntax when an error appears
- Read the first compiler error and inspect the statement it identifies.
- Check the keyword's spelling and the required parts of the statement, such as Then or As.
- Match opening and closing block statements, including Sub with End Sub and For with Next.
- Check whether an identifier conflicts with a reserved word. Rename it where practical, or escape it when necessary.
- Build again, then exercise each relevant branch or loop to check its behaviour.
Choose a short example from the Visual Basic guides and identify its keywords, identifiers and member names. Then change one condition and run it to see which instructions execute.
Other editions for separate workloads
Other editions for separate workloads; prices in AUD, confirm the total on the listing.
-

Windows 11 Pro key
$14.99 AUD
$29.00 -

Office 2024 Pro Plus key
$20.00 AUD
$39.00 -

Windows 11 Home key
$18.88 AUD
$37.00
How to check this worked
- Open Settings, System, Activation and confirm the edition shown.
- Enter the key and run activation; expect a green tick within a minute.
- Reboot and re-check activation survives the restart.
FAQ
What else should you know before buying?
- What do I need before starting?
- Read the requirements and confirm the edition first; the steps assume the machine is compatible.
- How do I know the licence is genuine?
- Activate on Microsoft's servers and check Settings, System, Activation. A working activation is the test.
- Is this a subscription?
- Keys sold here are one-time lifetime licences. Microsoft 365 plans are billed by Microsoft instead.
- What if the key fails?
- Email hi@ms.codes with the order number and a screenshot. Replacement or refund applies within 30 days.
Check who prepared and reviewed this guide
- Written by
- MS.Codes editorial
- Reviewed by
- Support team
Last verified: (source review; see test status above).