CST2601 Visual
Basic I
Notes on Len Function
Len FunctionReturns a Long containing the number of characters in a string or the number of bytes required to store a variable. Syntax Len(string | varname) The Len function syntax has these parts:
Remarks One (and only one) of the two possible arguments must be specified. With user-defined types, Len returns the size as it will be written to the file. Note Use the LenB function with byte data contained in a string, as in double-byte character set (DBCS) languages. Instead of returning the number of characters in a string, LenB returns the number of bytes used to represent that string. With user-defined types, LenB returns the in-memory size, including any padding between elements. For sample code that uses LenB, see the second example in the example topic. Note Len may not be able to determine the actual number of storage bytes required when used with variable-length strings in user-defined data types. Len Function ExampleThe first example uses Len to return the number of characters in
a string or the number of bytes required to store a variable. The Type...End
Type block defining
The second example uses LenB and a user-defined function (LenMbcs) to return the number of byte characters in a string if ANSI is used to represent the string.
|