Search notes:

Microsoft.VisualBasic.Information (class)

The Microsoft.VisualBasic.Information class provides procedures used to return, test for and verify data.

Using the class in PowerShell

In order to use this class in PowerShell, a reference to the Microsoft.VisualBasic assembly must be added:
add-type -assembly Microsoft.VisualBasic

Methods

Erl Line number of last statement that was executed.
Err An Microsoft.VisualBasic.ErrObject object that is used for error handling purposes.
IsArray
IsDate
IsDBNull Checks if an expression evaluates to a System.DBNull class.
IsError Checks if an expression derives from System.Exception.
IsNothing
IsNumeric
IsReference
LBound
QBColor
RGB
SystemTypeName
TypeName
UBound
VarType
VbTypeName

IsNumeric

IsNumeric(expr) returns true if expr can be evaluated as a numerical value.
add-type -assembly Microsoft.VisualBasic

[Microsoft.VisualBasic.Information]::IsNumeric(  42       )  # True
[Microsoft.VisualBasic.Information]::IsNumeric(  42.1     )  # True
[Microsoft.VisualBasic.Information]::IsNumeric(" 42.1"    )  # True
[Microsoft.VisualBasic.Information]::IsNumeric(" 42.1"    )  # True
[Microsoft.VisualBasic.Information]::IsNumeric(" 42.1 xyz")  # False
[Microsoft.VisualBasic.Information]::IsNumeric( $true     )  # True
[Microsoft.VisualBasic.Information]::IsNumeric( $false    )  # True

TypeName

TypeName(…) returns a COM object's type name like VBA's function typeName() does.
In PowerShell, TypeName() might be used like so:
$comObj = [System.Runtime.InteropServices.Marshal]::GetActiveObject('Excel.Application')

#
#  Adding the Micrsoft.VisualBasic.Information type so that we can use its TypeName() function
#
  add-type  -assemblyName Microsoft.VisualBasic
#
#   Alternatively, adding it with the path to the DLL:
# add-type -path 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\Microsoft.VisualBasic.dll'

[Microsoft.VisualBasic.Information]::TypeName($comObj.worksheets(1).shapes(1))

#
#  Creating an «alias» for the namespace:
#
$vbi = [Microsoft.VisualBasic.Information]
$vbi::TypeName($comObj.selection)
Instead of using a variable $vbi to refer to a the Microsoft.VisualBasic.Information type, it also possible to add a type accelerator for this type (so that the TypeName() can be invoked like so [vbi]::TypeName())

Index