MID                                  '  VB style

#include <VBSTRING.bas>                        ' source in /Program Files/Coridium/BASIClib 

FUNCTION MID( string , start, length ) as STRING


This FUNCTION written in BASIC returning the portion of string from the start character for length characters.

String may be a constant or variable string.

start is based on 1 being the first character, which is consistent with the MID VB function, but inconsistent with the VB search.chars(0) being the first character.  The C style MIDSTR version of this routine uses 0 as the first character.

Extracting or setting a single byte in a string can be done with an index STRING(3) refers to the 4th byte of the string (starts from 0).


#include <VBSTRING.bas> 
DIM text(10)
text = "HELLO WORLD" 
PRINT MID(text, 4,5)     ' will display  LO WO

Differences from other BASICs

See also