Requires: GfaWinx.lg32
Retiurn the length and memory position of a string inside a Variant.
chars% = VStrLen(vstring)
bytes% = VStrLenB(vstring)
ptr% = VStrPtr(vstring)
chars%, length%, mempos% | : integer variables |
vstring | : string in a variant |
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.
$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)
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.
{Created by Sjouke Hamstra; Last updated: 07/03/2022 by James Gaite}