VB.Net - Syntax
Is Operator
The Is operator checks if the run-time type of an expression result is compatible with a given type.
Dim oDataGridViewCell As System.Windows.Forms.DataGridViewCell
oDataGridViewCell = Me.dgrDataGridView.Rows(e.RowIndex).Cells(e.ColumnIndex)
If (TypeOf oDataGridViewCell Is System.Windows.Forms.DataGridViewCheckBoxCell) Then
This is frequently used in conjunction with the TypeOf Operator.
TypeName
This function returns a string containing the name of the data type that is stored in a variable.
Dim sMyType As String
Dim sStringVar As String
Dim iIntegerVar As Integer
sMyType = Microsoft.VisualBasic.Information.TypeName(sStringVar) ' Returns "String".
sMyType = Microsoft.VisualBasic.Information.TypeName(iIntegerVar) ' Returns "Integer".
The equivalent in C# is to use the object.GetType() method.
This function is available in VBA
TypeOf Operator
The TypeOf operator is used for checking if an object is of a particular type.
The way to check if an object is of a particular type is to use the TypeOf operator
This is frequently used in conjunction with the Is Operator.
If (TypeOf myobject Is Dog) Then
End If
result = TypeOf x Is Integer
There is no equivalent in C#.
There is a typeof Operator in C# but it has a different meaning - which is extremely confusing.
This operator is available in VBA
GetType Operator
This has nothing to do with the .NET framework and was originally part of Visual Basic 6.0.
The GetType operator requires that you pass the data type in.
Do not confuse this with the .NET Framework object.GetType() method.
Dim t As Type = GetType(String)
The equivalent in C# is to use the typeof Operator.
This operator is not available in VBA.
© 2026 Better Solutions Limited. All Rights Reserved. © 2026 Better Solutions Limited TopPrevNext