String to Array and Array to String 
Author Message
 String to Array and Array to String

Does anyone know how to convert a string to an array or vice-versa?

Thanks in advance,
Michael



Mon, 24 Jun 2002 03:00:00 GMT  
 String to Array and Array to String
If you mean a byte array, then I believe a direct assignment will work:
abytSome()=strSome and visa versa. You may want to use StrConv function
to convert VBA strings from/to Unicode.
Quote:

> Does anyone know how to convert a string to an array or vice-versa?

> Thanks in advance,
> Michael



Mon, 24 Jun 2002 03:00:00 GMT  
 String to Array and Array to String
Since no one has posted an answer, I assume that means you have to parse the
string in code, and build the string in code.

To build a text string of semi-colon delimited values:

for i = 1 to YourLastArrayElement
    strVar=strVar & aMyArray(i) & ";"
next i

' Strip off the last semi-colon:
strVar=left(strVar,len(strVar)-1)

    - or, to move from the string with semi-colon delimited values to an
array:

i=0

DO WHILE  LEN(nz(strVar))>0
    iPos=instr(strVar,";")
    IF iPos > 0 THEN
        aMyArray(i)=left(strVar,iPos - 1) & ";"
        i = i + 1
        strVar=mid(strVar,iPos + 1)
    ELSE  'this is the last value
        aMyArray(i)=strVar
        strVar=""
    END IF
END DO


Quote:
> Does anyone know how to convert a string to an array or vice-versa?

> Thanks in advance,
> Michael



Sun, 07 Jul 2002 03:00:00 GMT  
 String to Array and Array to String
Well, if this is in VBA6 you can sue the Split and Join functions.

--
?MichKa
(insensitive fruitarian)

random junk of dubious value, a multilingual website, the
48-language TSI Form/Report to Data Access Page Wizard,
and lots of replication "stuff" at http://www.trigeminal.com/

?

Quote:
> Since no one has posted an answer, I assume that means you have to parse
the
> string in code, and build the string in code.

> To build a text string of semi-colon delimited values:

> for i = 1 to YourLastArrayElement
>     strVar=strVar & aMyArray(i) & ";"
> next i

> ' Strip off the last semi-colon:
> strVar=left(strVar,len(strVar)-1)

>     - or, to move from the string with semi-colon delimited values to an
> array:

> i=0

> DO WHILE  LEN(nz(strVar))>0
>     iPos=instr(strVar,";")
>     IF iPos > 0 THEN
>         aMyArray(i)=left(strVar,iPos - 1) & ";"
>         i = i + 1
>         strVar=mid(strVar,iPos + 1)
>     ELSE  'this is the last value
>         aMyArray(i)=strVar
>         strVar=""
>     END IF
> END DO



> > Does anyone know how to convert a string to an array or vice-versa?

> > Thanks in advance,
> > Michael



Sun, 07 Jul 2002 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. String data conversion from byte array to a string

2. Object array to string array

3. BinaryRead - howto convert binary string back to string array

4. Converting a string array into a double array

5. Converting string array to byte array

6. spit a string into an array

7. Help with converting string to Array

8. Coverting a comma delimmetted string to an array

9. passing string arrays, v2.0

10. Array of Strings

11. how to pass a string array to mfc dll

12. String to a byte array

 

 
Powered by phpBB® Forum Software