
"X$", "Y$" may be a string variable, string expression, or string constant.
If Y$ is found in X$, INSTR returns the position of the first occurrence of Y$ in X$,
from the starting point.
If N is larger than the length of X$ or if X$ is null, of if Y$ cannot be found, INSTR
returns 0.
If Y$ is null, INSTR returns N (or 1 if N is not specified).
Example
String1$ = "11025John Thomas, Accounting Manager"
String2$ = ","
EmployeeName$ = MID$(String1$, 6, INSTR(String1$, String2$) - 6)
' the employee's name starts at the sixth character
5.4.5 Retrieving Part of Strings
Several commands are provided to take strings apart by returning pieces of a string, from
the left side, or the right side, or the middle of the target string.
LEFT$
Purpose
To retrieve a given number of characters from the left side of the target string.
Syntax
A$ = LEFT$(X$, N%)
Remarks
"A$" is a string variable to be assigned to the result.
"N%" is a numeric expression in the range of 0 to 255.
"X$" may be a string variable, string expression, or string constant.
If N is larger than the length of X$, the entire string (X$) is returned.
If N is zero, the null string (with lenght 0) is returned.
Example
String1$ = "11025John Thomas, Accounting Manager"
EmployeeID$ = LEFT$(String1$, 5)
MID$
Purpose
To retrieve a given number of characters from anywhere of the target string.
Kommentare zu diesen Handbüchern