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

' This code is licensed according to the terms and conditions listed here.

' 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

Go back to the alphabetical Function listing.
Go back to the Reference section index.


Last Modified: December 21, 1999
This page is copyright © 1999 Paul Kuliniewicz. Copyright Information Revised October 29, 2000
Go back to the Windows API Guide home page.
E-mail: vbapi@vbapi.com Send Encrypted E-Mail
This page is at http://www.vbapi.com/ref/l/lstrlen.html