472,146 Members | 1,273 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,146 software developers and data experts.

Turn a String Into An Array of Characters

Is there a function in VBA to convert a string to an array of characters. I'm
looking for the exact same functionality as the ToCharArray() method in C#.
If this functionality does not exist, do y'all have any pre-written code to
do this?

Psuedo-Hopeless Request-
Dear Microsoft: It would be cool if VBA had more robust string manipulation
functions like those in C#, which kick a*s.

TIA
Johnny
Nov 12 '05 #1
5 27758
me**************@msn.com (Johnny Meredith) wrote in
news:70**************************@posting.google.c om:
Is there a function in VBA to convert a string to an array of
characters. I'm looking for the exact same functionality as the
ToCharArray() method in C#. If this functionality does not exist, do
y'all have any pre-written code to do this?

Psuedo-Hopeless Request-
Dear Microsoft: It would be cool if VBA had more robust string
manipulation functions like those in C#, which kick a*s.


I guess you could just write all the functions you want in C++, compile them
into a DLL, and reference the DLL from Access. Sounds like a piece of cake to
me, as these string manipulation functions in C++ kick a*s!

Why not do that and then share it with your buddies here at CDMA, Johnny!?

Oh Yeah ... Access-VBA has this "Help" file. Try looking in there. You could
find something like Split ... not really, you could!

--
Lyle
(for e-mail refer to http://ffdba.com/contacts.htm)
Nov 12 '05 #2
rkc

"Johnny Meredith" <me**************@msn.com> wrote in message
news:70**************************@posting.google.c om...
Is there a function in VBA to convert a string to an array of characters. I'm looking for the exact same functionality as the ToCharArray() method in C#. If this functionality does not exist, do y'all have any pre-written code to do this?


Why? What do you want to do with the array once you have it?
There's the Mid$ function that allows access to each individual character.
Look under the help topic example for StrConv for another possible solution.

Nov 12 '05 #3
Just to expand on what rkc said, note that the Mid function can actually be
used on the left hand side of the = assignment, so it truly does give you all
the capabilities of an array of characters, both for reasing and for
assignment.

Of course, that's still nothing like what C# or Java have, but I don't think
it would be a good idea to add that kind of string to VB/VBA since it's so
very different from what we've all learned to expect from those languages. of
course, you could write your own String and Stringbuffer classes if you want
to. Someone might even have done it already and has it somewhere for
download.

On 2 Apr 2004 08:54:46 -0800, me**************@msn.com (Johnny Meredith)
wrote:
Is there a function in VBA to convert a string to an array of characters. I'm
looking for the exact same functionality as the ToCharArray() method in C#.
If this functionality does not exist, do y'all have any pre-written code to
do this?

Psuedo-Hopeless Request-
Dear Microsoft: It would be cool if VBA had more robust string manipulation
functions like those in C#, which kick a*s.

TIA
Johnny


Nov 12 '05 #4
On Apr 02 2004, 11:54 am, me**************@msn.com (Johnny Meredith)
wrote in news:70**************************@posting.google.c om:
Is there a function in VBA to convert a string to an array of
characters. I'm looking for the exact same functionality as the
ToCharArray() method in C#.


I'm not sure what ToCharArray() does, but perhaps you can use something
like this:

Dim str as String
Dim ArrayOfBytes() As Byte

str = "ToCharArray"
ArrayOfBytes() = str

Keep in mind that strings in VBA are Unicode.

--
remove a 9 to reply by email
Nov 12 '05 #5
"rkc" <rk*@yabba.dabba.do.rochester.rr.bomb> wrote in
news:Ya*****************@twister.nyroc.rr.com:
"Johnny Meredith" <me**************@msn.com> wrote in message
news:70**************************@posting.google.c om...
Is there a function in VBA to convert a string to an array of
characters.

I'm
looking for the exact same functionality as the ToCharArray()
method in

C#.
If this functionality does not exist, do y'all have any
pre-written code

to
do this?


Why? What do you want to do with the array once you have it?
There's the Mid$ function that allows access to each individual
character. Look under the help topic example for StrConv for
another possible solution.


"Why?" is certainly the right question.

Any post that begins "how can I do in Access this thing I do in
language X?" is probably going to be a question based on a
misapprehension of the best way to get the task done in Access based
on knowledge from a domain that no longer applies.

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
Nov 12 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Garfield | last post: by
6 posts views Thread by Bruce Wiebe | last post: by
5 posts views Thread by Paulers | last post: by
10 posts views Thread by Visual Systems AB \(Martin Arvidsson\) | last post: by
8 posts views Thread by Pim75 | last post: by
2 posts views Thread by LinLMa | last post: by
Osoascam
1 post views Thread by Osoascam | last post: by
reply views Thread by Saiars | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.