Split string to char ?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi guys

I have a 50 charecters long string and I need to examine every charectar individually, I thought of converting the string into and Char array of 50 and then go over the array, how can I split the string into my char array ? I do not have a delimiter between the characters in my string ( it looks like "000010100101......"
Or maybe there is a better way to examine each char (while knowing the char's position in the string) ?

Thanks !
 
Hi guys,

I have a 50 charecters long string and I need to examine every charectar individually, I thought of converting the string into and Char array of 50 and then go over the array, how can I split the string into my char array ? I do not have a delimiter between the characters in my string ( it looks like "000010100101......")
Or maybe there is a better way to examine each char (while knowing the char's position in the string) ??

Thanks !

There's (at least) a couple of ways you can go about it..

Example 1:

Dim szText As String = "some text that you want to work on"
Dim ch() As Char = szText.ToCharArray()

... then use the ch() char array

Example 2:

Dim szText As String = "some text that you want to work on"

For Each ch As Char In szText
'Process character in ch
Next


// CHRIS
 
* =?Utf-8?B?T3JpIDop?= said:
I have a 50 charecters long string and I need to examine every charectar individually, I thought of converting the string into and Char array of 50 and then go over the array, how can I split the string into my char array ? I do not have a delimiter between the characters in my string ( it looks like "000010100101......")

\\\
Dim c As Char
For Each c In "Hello World"
MsgBox(c)
Next c
///
 
Ori,
In addition to the others comments, you can also use the Chars (indexed)
property of String to access individual characters.

Dim s As String
Dim ch As Char
For index As Integer = 0 to s.Length -1
ch = s.Chars(index)
Next

I normally use the other two techniques over this one, just wanted to give
you a third alternative.

Hope this helps
Jay

Ori :) said:
Hi guys,

I have a 50 charecters long string and I need to examine every charectar
individually, I thought of converting the string into and Char array of 50
and then go over the array, how can I split the string into my char array ?
I do not have a delimiter between the characters in my string ( it looks
like "000010100101......")
Or maybe there is a better way to examine each char (while knowing the
char's position in the string) ??
 
Back
Top