By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,098 Members | 936 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,098 IT Pros & Developers. It's quick & easy.

Turn a String Into An Array of Characters

P: n/a
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
Share this Question
Share on Google+
5 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
"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.