Len
Returns the length of a variable or data type
Syntax
`
Declare Function Len ( ByRef variable As Any ) As Integer
Declare Function Len ( datatype ) As Integer
`
Usage
`
result = Len( variable )
`or`
`
result = Len( DataType )
Parameters
`variable`
A variable of any type.
`datatype`
A DataType.
Return Value
Returns the size of a variable or DataType in bytes.
Description
`Len` returns the length of a variable or DataType, in bytes.
In the first form, if `variable` is of type `String`, `WString` or `ZString`, the length of the string in characters will be returned. Otherwise, the size of `variable`'s type in bytes is returned.
In the second form, if `datatype` is `ZString` or `WString`, the size of an ASCII or Unicode character is returned, respectively. If `datatype` is `String`, the size of the string descriptor type is returned.
If there is both a user defined type and a variable both having the same name in the same scope, the user defined type takes precedence over the variable. To ensure that the `Len` takes the variable instead of the user defined type, wrap the argument to `Len` with parentheses to force it to be seen as an expression. For example `Len((variable))`.
Example
`
Print Len("hello world") 'returns "11"
Print Len(Integer) ' returns 4
Type xyz
a As Integer
b As Integer
End Type
Print Len(xyz) ' returns 8
`
Dialect Differences

- `Len` only allows expressions in the -lang qb dialect.
- Can be used with built-in types and user-defined types in the -lang fb and -lang fblite dialects.

Differences from QB

- Can be used with built-in types and user-defined types in the -lang fb and -lang fblite dialects.
- None in the -lang qb dialect.

See also

- `SizeOf`