Split string to char ?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ori :)

    Split string to char ?

    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 !
  • Chris Morse

    #2
    Re: Split string to char ?

    On Fri, 27 Feb 2004 12:01:05 -0800, =?Utf-8?B?T3JpIDop?=
    <anonymous@disc ussions.microso ft.com> wrote:
    [color=blue]
    >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 ![/color]

    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.ToCharAr ray()

    ... 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

    Comment

    • Herfried K. Wagner [MVP]

      #3
      Re: Split string to char ?

      * =?Utf-8?B?T3JpIDop?= <anonymous@disc ussions.microso ft.com> scripsit:[color=blue]
      > 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.. ....")[/color]

      \\\
      Dim c As Char
      For Each c In "Hello World"
      MsgBox(c)
      Next c
      ///

      --
      Herfried K. Wagner [MVP]
      <http://dotnet.mvps.org/>
      Website Address Changed!

      Comment

      • Jay B. Harlow [MVP - Outlook]

        #4
        Re: Split string to char ?

        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 :)" <anonymous@disc ussions.microso ft.com> wrote in message
        news:F36E3052-CF46-463B-88CE-DDA747FB49BC@mi crosoft.com...[color=blue]
        > Hi guys,
        >
        > I have a 50 charecters long string and I need to examine every charectar[/color]
        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.. ....")[color=blue]
        > Or maybe there is a better way to examine each char (while knowing the[/color]
        char's position in the string) ??[color=blue]
        >
        > Thanks ![/color]


        Comment

        • Ori :)

          #5
          Re: Split string to char ?

          Thanks guys ! works gr8 :)

          Comment

          Working...