VB provides string functions such as Left ,Right ,len.
Syntax is as follows:
Left(String Expression, no. of characters)
Right(String Expression, no. of characters)
String expression in Left and Right statements may be a string variable, string literal or text properties. Number of characters and start position are both numeric and may be variables, literals or numeric expressions.
„Returns first 5 characters
„Returns last one character
We can use the len function to determine the length of string expression. We may need to know how many characters the user has entered or how long list element is. The value returned by the len function is an integer count of the number of characters in the string.
Ex. Len(“Visual Basic”)
„Returns no. of character as 12
„Returns no. of character in the textbox
If len(txtNames.text)=0 then
Msgbox “Enter a Name”,VBInformation,”DataMissing”