Implicit Conversion

Is invoked automatically when a value of one data type is assigned to a value of another. Widening casts are often implicit.
An implicit data type conversion is a conversion that happens automatically.
VBA provides implicit conversion for a large number of data types
A string representation of a number will even be implicitly converted to a Long

Dim sNumber As String 
sNumber = "20"
Dim lNumber As Long
lNumber = sNumber

You can assign a string to a numeric variable if the string represents a number
You can also assign a numerical value to a string variable.

Dim lNumber As Long 
Dim sNumber As String
sNumber = "100"
lNumber = sNumber
sNumber = lNumber
Call MsgBox(sNumber)

Variant Data Type

When a variable is declared as a Variant data type all the conversions are done implicitly.
show examples

© 2023 Better Solutions Limited. All Rights Reserved. © 2023 Better Solutions Limited TopPrevNext