lstrlen Function

Declare Function lstrlen Lib "kernel32.dll" Alias "lstrlenA" (ByVal lpString As Any) As Long

Platforms

Description & Usage

lstrlen determines the length of a string. The length of a string is considered to be the number of characters it contains, not counting any possible terminating null character. This function can also determine the length of a string to which a pointer refers.

Return Value

The function returns the length of the string, measured in number of characters.

Visual Basic-Specific Issues

This function is very useful, in conjunction with lstrcpy, for "converting" a pointer to a string into an actual string.

Parameters

lpString
Either the string to determine the length of or a pointer to the string to determine the length of.

Example

' Display the length of the string "Hello, world!"
Dim slength As Long  ' receives the length of the string

slength = lstrlen("Hello, world!")  ' find the length of the string
Debug.Print "The string 'Hello, world!' contains"; slength; "characters."

Category

Strings

Back to the index.


Last Modified: December 21, 1999
This page is copyright © 1999 Paul Kuliniewicz. Copyright Information

Go to Paul Kuliniewicz's Home Page.
E-mail: rogue953@hotmail.com
This page is at http://skyscraper.fortunecity.com/transmission/45/api/l/lstrlen.html