Qbasicnews.com

Full Version: string to array?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
How can I convert a string such as a$ to an array, where each part of the array contains one letter of the string.

for example


a$ = "cat"
dim array(3)

...


print array(1) 'should print c
print array(2) 'should print a
print array(3) 'should print t

etc
DIM, MID$() and LEN() and a FOR loop.

Here is the code:


len.a% = len(a$)
DIM array1$(1 TO len.a%)
FOR i% = 1 TO len.a%
array1$(i%) = MID$(a$, i%, 1)
NEXT i%
Thanks agamemnus, any particular reason for the mini font size?
Maybe he wants you to write the code on your own...
I jst copied to word and increased the font size, but forgot to save the file so I wrote it myself anyway
You can also copy to notepad... I always do that when printing news from a website that has annoying html gimmick stuff..
Quote:You can also copy to notepad... I always do that when printing news from a website that has annoying html gimmick stuff..
Jep..that's what I do..it's the best solution
or use mozilla. perfect size scaling Smile