Code archives/Miscellaneous/Words into Array

This code has been declared by its author to be Public Domain code.

Download source code

Words into Array by dna2015
This routine chops up a sentence into individual words and puts them into an array.

In a sentence the space is the delimiter but you can substitute anything you like.
Dim a$(20):E$="word1 word2 word3"
IN=Instr(E$," ")
While IN>0
	X=X+1:A$(X)=Left$(E$,IN):E$=Mid$(E$,IN+1):IN=Instr(E$," ")
Wend
X=X+1:A$(X)=E$
For G=1 To X:Print A$(G):Next
WaitKey:End

Comments

None.

Code Archives Forum