Database development and training for Birmingham and the midlands
Specialists in Microsoft Access and Visual Foxpro database training and development
I am happy to hear from existing clients but I am taking no new calls.
Visual Basic and Visual FoxPro substrings
VBALeft(), Right(), Mid(); |
VFPLeft(), Right(), SubStr(), StrExtract() |
Common Syntax Notes
The Left() and Right() functions are the same in both languages. Both take a string and a number as parameters and both will return the leftmost or rightmost n characters of that string. The expression:
will return the first five characters of the first parameter passed into the function and will give you the string "Hello".
Note that both languages are 1-based. The first character of the string is character number 1, not zero. In VBA you can use Option Base 0 to force array elements to begin numbering at zero but this option does not affect the way that characters are numbered within a string.
Visual Basic Syntax Notes
VBA uses Mid() to return characters from the middle of the string.
All the VBA string processing functions exist in two forms, one of which has a "$" suffix to indicate that the function will return a string. As an example, the Left() function returns the leftmost characters as a variant data type whereas the Left$() functions returns them as a string.
Visual FoxPro Syntax Notes
VFP uses the SubStr() function to read characters from the middle of a string and also has the StrExtract() function to return the characters between two specified delimiters in a string.
FoxPro has always been a weakly-typed language so there is no need for the distinction between variant (all Fox variables are variant) and string functions. Visual FoxPro does have a set of text-handling functions with a "C" suffix which handle strings in double-byte character sets, for example LeftC().