Visual Basic.net(VB.net) - Cheat Sheets
Visual Basic.net(VB.net) - Cheat Sheets
+2
Basics
Sample Program
Public Module : Every program contains a module which has the data and
procedures that your program uses. Here we are declaring module named
Program with public visibility.
Main : Beginning of your program
Console.WriteLine : Console is a class of the System namespace and
WriteLine() is a method in it which is used to print text to the console.
VB.net is not a Case-sensitive language
' : Single line Comment
Data types
used to store
byte 0 to 255 1 byte
unsigned integer
https://onecompiler.com/cheatsheets/vb 1/8
2/4/24, 9:25 PM Visual Basic.net(VB.net) - Cheat Sheets - OneCompiler
used to store
ushort 0 to 65,535 2 bytes
unsigned integers
-9,223,372,036,854,77
used to store signed 5,808 to
long 8 bytes
integers 9,223,372,036,854,775
,807
used to store
double 15 decimal digits 8 bytes
fractional numbers
0:00:00 January 1,
Used to store date
date 0001 to 23:59:59 8 bytes
values
December 31, 9999
0 to
+/-7.92281625142643
used to store decimal
decimal 37593543950335 with 16 bytes
values
28 places to the right of
the decimal
Stores a sequence of
String characters enclosed Sequence of Characters 2 bytes per character
in double quotes
Object can be
4 bytes on 32-bit
represented as base
object platform and 8 bytes
type of all other
on 64-bit platform
types.
Variables
Example
https://onecompiler.com/cheatsheets/vb 2/8
2/4/24, 9:25 PM Visual Basic.net(VB.net) - Cheat Sheets - OneCompiler
Constants
Operators
BitWise Operator AND, OR, XOR, NOT, AndAlso, OrElse, isTrue, isFalse
https://onecompiler.com/cheatsheets/vb 3/8
2/4/24, 9:25 PM Visual Basic.net(VB.net) - Cheat Sheets - OneCompiler
Strings
Conditional Statements
1. If
If condition-expression Then
'code
End If
2. If-else
If(conditional-expression)Then
'code if the conditional-expression is true
Else
'code if the conditional-expression is false
End If
3. If-else-if ladder
If(conditional-expression)Then
'code if the above conditional-expression is true
Else If(conditional-expression) Then
'code if the above conditional-expression is true
Else
'code if the above conditional-expression is false
End If
4. Nested-If
If(conditional-expression)Then
'code if the above conditional-expression is true
If(conditional-expression)Then
'code if the above conditional-expression is true
End If
End If
5. Select Case
https://onecompiler.com/cheatsheets/vb 4/8
2/4/24, 9:25 PM Visual Basic.net(VB.net) - Cheat Sheets - OneCompiler
Loops
1. For..Next
2. For..Each
3. While
While conditional-expression
'Code
[ Continue While ]
'Code
[ Exit While ]
'Code
End While
4. Do-while
'Code
Loop
Do
'Code
[ Continue Do ]
'Code
[ Exit Do ]
'Code
Loop { While | Until } conditional-expression
Functions
Functions consists of a set of statements which perform a sepcific functionality and
they return a value when they are called.
Sub-Procedures
Sub-procedures are similar to functions but they don't return any value.
OneCompiler.com
About
Contact
Users
Status
Pricing
https://onecompiler.com/cheatsheets/vb 6/8