VStrLen,VStrLenB and VStrPtr functions

Requires: GfaWinx.lg32

Purpose

Retiurn the length and memory position of a string inside a Variant.

Syntax

chars% = VStrLen(vstring)
bytes% = VStrLenB(vstring)
ptr% = VStrPtr(vstring)

chars%, length%, mempos%: integer variables
vstring: string in a variant

Description

VStrLen and VStrLenB return the length of a string inside a Variant, the first counting characters, the second bytes. VStrPtr returns the string's position in memory.

Example

$Library "GfaWinX"

Local vstr As Variant = "String in a variant"

Print "Length in characters:"; VStrLen(vstr)

Print "Length in bytes:"; VStrLenB(vstr)

Print "Memory Position:"; VStrPtr(vstr)

Remarks

As Windows usually stores stings inside a Variant in BSTR format, which allocates two bytes per charcter, the length in bytes is usually twice that of the length in characters.

See Also

Variants in Strings

{Created by Sjouke Hamstra; Last updated: 07/03/2022 by James Gaite}