Purpose
Returns a string containing the leftmost characters of a string argument.
Syntax
Left (StringExpression, NumericExpression)
StringExpression |
Any valid string. |
NumericExpression |
Any valid integer greater than or equal to 0. If NumericExpression is greater than or equal to the length of StringExpression, the entire string is returned. |
Example
Sub Main()
Dim s As String, Ioc As Integer
s = "the quick fox jumps over the dog"
Ioc = InStr(s, " ") 'find the first occurrence of a space character
If Ioc<>0 Then
Print "The first word in the sentence is:"; Left(s, Ioc - 1)
Print "The rest of the sentence is:"; Right(s, Len(s) - Ioc)
Else
print "Invalid sentence (no spaces)."
End If
End Sub
|