MID$
From QB64 Wiki
The MID$ function returns a portion of a STRING's value from any position inside a string.
- MID$(stringvalue$, startposition%[, bytes%])
- stringvalue can be any literal or variable STRING value having a length. See LEN.
- startposition designates the non-zero position of the first character to be returned by the function.
- bytes (optional) tells the function how many characters to return including the first character when it is used.
Usage:
- When the bytes value is not used the function returns the remainder of the string from the starting character position.
- Number of character bytes should be within the string's length from the start position, but will only return the string's remainder when exceeded.
- If the bytes value is 0 or the start position is 0 or greater than the length of the string, nothing is returned (no error).
- In QBasic the start position cannot be zero(0) or an Illegal function call error will occur.
Example: Getting the hour and minutes from TIME$
PRINT TIME$ hour$ = LEFT$(TIME$, 2) minutes$ = MID$(TIME$, 4, 2) ' skip hours and the colon (3 characters) PRINT "hour = "; hour$; ": minutes = "; minutes$
11:23:30 hour = 11: minutes = 23
See also: