<-- Previous || Up || Next -->

Get VB Token Function
String Extras Class

Public Function GetVBToken( _
    ByRef rLine As String _
    ) As String

"Get Visual Basic Token"
Simple but powerful and almost complete lexical analyzer for Visual Basic code.
Removes and returns the next Visual Basic token from a string containing Visual Basic code.

       Dim strCode As String
       strCode = "strSample = 45"
    For example
       GetVBToken(strCode) = "strSample"
       strCode = "= 45"
See also:
    GetVBTokenSample Subroutine
    GetPossiblyQuotedField Function
    GetToken Function, et. al.
    GetOpt Function
    VBAReservedWords Property
Future: Need to consider returning a code describing the type of the unit retrieved.
Future: Need to handle numeric constants differently and separately from strings.
Note: Function uses the built-in character classification routines to determine which characters are alphanumeric.

rLine: String containing the Visual Basic code from which the next token will be removed then returned as the value of the function. Function returns an empty string when rLine is an empty string.

This function recognizes the following types of Visual Basic tokens:
Numeric constants and identifiers which are repeated runs of alphanumeric characters.
Comments which begin with a single-quote (') character.
String literals which are enclosed within double-quote (") characters.
Bracketed identifiers such as object names like "[First Name]".
Hexadecimal constants introduced by ampersand (&) characters.

Note: String literals can contain embedded double-quote characters by placing an additional double-quote character (as allowed by Visual Basic), but this function does not remove the extra double-quote character from embedded double-quotes, but it does remove the two double-quote characters which surround the string literal.

Copyright 1996-1999 Entisoft
Entisoft Tools is a trademark of Entisoft.