Javatpoint Logo
Javatpoint Logo

VB.NET Keywords

A keyword is a reserved word with special meanings in the compiler, whose meaning cannot be changed. Therefore, these keywords cannot be used as an identifier in VB.NET programming such as class name, variable, function, module, etc.

In this section, we will understand about the VB.NET identifier, VB.NET comment, and how we can use it in VB.NET.

There are following reserved keyword available in the VB.NET language.

AddHandler AddressOf Alias And AndAlso As
Boolean ByRef Byte ByVal Call Case
Catch CBool CByte CChar CDate CDbl
CDec Char Cint Class CLng CObj
Const Continue CSByte CShort CSng CStr
CType CUnit CULng CUShort Date Decimal
Declare Default Delegate Dim DirectCast Do
Double Each Else Elseif End End if
Enum Erase Error Event Exit False
Finally For Friend Function Get GetType
GetXML Namespace Global GoTO Handles If Implements
Imports In Inherits Integer Interface Is
isNot Let Lib Like Long Loop
Me Mod Module MustInherit MustOverride MyBase
MyClass Namespace Narrowing New Next Not
Nothing Not Inheritable Not Overridable Object Of On
Operator Option Optional Or OrElse Overloads
Overridable Overrides ParamArray Partial Private Property
Protected Public RaiseEvent ReadOnly ReDim REM
Remove Handler Resume Return SByte Select Set
Shadows Shared Short Single Static Step
Stop String Structure Sub SyncLock Then
Throw To True Try TryCast TypeOf
UInteger While Widening With WithEvents WhiteOnly
Xor #Else IsReference TimeOfDay Append Auto

Let's create a program to find the area and perimeter of a rectangle in VB.NET.



Length is: 5
Breadth is: 6
Area of Rectangle is: 30
Perimeter of Rectangle is: 22
Press any key to exit...

VB.NET Identifiers

As the name defines, an identifier is used to identify the name of variable, function, class, or any other user-defined elements in the program. An identifier should be the combination of letter, digit, and underscore. Still, the first character of the identifier or variable name should start with alphabet letter or underscore (_) of any length.

There are various rules for identifier in VB.NET, as follows:

  1. The first character of an identifier must start with an alphabet or underscore, that could be followed by any sequence of digits (0-9), letter or underscore.
  2. An identifier should not contain any reserved keyword.
  3. It should not start with any digit.
  4. It should not more than 51 characters.
  5. An identifier can contain two underscores, but should not be consecutive.
  6. It should not include any commas or white spaces in-between characters.

Generally, identifiers are meaningful names. Some valid identifiers are:

Value, a, rec1, my_data, Marks, num, etc.

Some invalid identifiers are:

5be             : First character should be alphabets or underscore (_)

Class, Shared     : Keyword are not allowed as identifier name.

A# -             : Identifier does not contain any special symbol.

Avg marks             : It should not contain any blank space.


Let's compile and execute the above program.


Hello friends...
Nice to meet you...
press any key to exit...

VB.NET Comments

A comment is used to explain the various steps that we have taken in our programming. The compiler ignores these comment statements because the compiler is not executed or processed in VB.NET. Therefore, it does not take any place in your compilation code.

In VB.NET, we use ( ' ) symbol to comment a statement.


Now compile and execute the above program.


Radius is: 10 Circumference of Circle: 62.8
 press any key to exit...

Hence, it is the best way to explain every step of VB.NET programming language.

Next TopicVB.NET Data Type

Youtube For Videos Join Our Youtube Channel: Join Now


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Trending Technologies

B.Tech / MCA