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

How do I convert a single character, e.g. "a" into char

P: n/a
How do I convert a single character, e.g. "a" into char
for use in the 'split' command?

p.s.
I have option strict on

Tia.
Nov 21 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
ctype("a", char)
<tt> wrote in message news:uT**************@TK2MSFTNGP12.phx.gbl...
How do I convert a single character, e.g. "a" into char
for use in the 'split' command?

p.s.
I have option strict on

Tia.

Nov 21 '05 #2

P: n/a
add a 'c' to denote character in your split call after your character to
split on, are you sure it's even needed though?

dim s as string = "oneatwoathreeafour"
dim values() as string = s.split("a"c)
dim morevalues() as string = s.split("a")
both produce the same results.

<tt> wrote in message news:uT**************@TK2MSFTNGP12.phx.gbl...
How do I convert a single character, e.g. "a" into char
for use in the 'split' command?

p.s.
I have option strict on

Tia.

Nov 21 '05 #3

P: n/a

"Jared" <as***********@nospam.com> wrote in message
news:10*************@corp.supernews.com...
add a 'c' to denote character in your split call after your character to
split on, are you sure it's even needed though?

dim s as string = "oneatwoathreeafour"
dim values() as string = s.split("a"c)
yes, this worked, I like this.
dim morevalues() as string = s.split("a")
this will not work with option strict
both produce the same results.

<tt> wrote in message news:uT**************@TK2MSFTNGP12.phx.gbl...
How do I convert a single character, e.g. "a" into char
for use in the 'split' command?

p.s.
I have option strict on

Tia.



Nov 21 '05 #4

P: n/a
Tia,
As Jared suggested use a small c, as in "a"c.

You can also use String.ToCharArray if you want to convert multiple
character string to an array of Chars.

Dim command As String
Dim delims As String = ",./"
Dim args() As String

args = command.Split(delims.ToCharArray())

Would be the same as:

args = command.Split(","c, "."c, "/"c)

However I would use the char literal ("a"c) for single characters, I've used
ToCharArray where I read the delimiters from an "external" source (such as a
parameter to the constructor, or a config file).

Hope this helps
Jay

<tt> wrote in message news:uT**************@TK2MSFTNGP12.phx.gbl...
How do I convert a single character, e.g. "a" into char
for use in the 'split' command?

p.s.
I have option strict on

Tia.

Nov 21 '05 #5

P: n/a
Jay,

"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> schrieb:
As Jared suggested use a small c, as in "a"c.


The 'c' doesn't necessarily be a lower case character:

<URL:http://msdn.microsoft.com/library/en-us/vblr7/html/vadatChar.asp>

:-)

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 21 '05 #6

P: n/a
Herfried,
That's true, however VS.NET changes it to a small c, so why fight it ;-)

Jay

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:%2***************@tk2msftngp13.phx.gbl...
Jay,

"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> schrieb:
As Jared suggested use a small c, as in "a"c.


The 'c' doesn't necessarily be a lower case character:

<URL:http://msdn.microsoft.com/library/en-us/vblr7/html/vadatChar.asp>

:-)

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>

Nov 21 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.