Re: Splitting a string into separate characters




"KAREN27" <KAREN27@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:2424999D-6447-44D6-83CB-D7F6E8214F66@xxxxxxxxxxxxxxxx
> Hi all,
>
> Does anyone know of a VB Script that will split a string into separate
> characters.
>
> For example:
>
> 1. If I have a word stored in a variable (eg. testword).

testword = "testword"
testwordlen = len(testword)

> 2. Count the number of characters (which in this example would show 8 to
the
> user).

WScript.Echo testwordlen

> 3. Then separate the string so each letter is then stored individually
into
> an individual array item (which would be create 8 array items)

dim result()
redim result(testwordlen)

for ix = 1 to testwordlen
result(ix-1) = Mid(testword,ix,1)
next

> so then I can
> do things with each letter on its own.
>
> So if I address array item three, the letter I'm addressing is the letter
"s".

WScript.Echo "item 3 is " & result(3-1)

> Although I think the array item '3' is actually the second character 'e'
in
> VB Scripting as think it starts counting from zero.

Quite right.

/Al


.