Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. Visual Basic
  4. store String chars or substrings in Array

store String chars or substrings in Array

Scheduled Pinned Locked Moved Visual Basic
databasedata-structuresquestion
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Anonymous
    wrote on last edited by
    #1

    how do i take A strings data and take all the chars or substrings and store them Array INDividualy... so say if the data in the string is HELLO THERE take H and store it to index 0 E store it to index 1 and so on and so forth even the space between HELLO and THERE.

    A C S 3 Replies Last reply
    0
    • A Anonymous

      how do i take A strings data and take all the chars or substrings and store them Array INDividualy... so say if the data in the string is HELLO THERE take H and store it to index 0 E store it to index 1 and so on and so forth even the space between HELLO and THERE.

      A Offline
      A Offline
      Anonymous
      wrote on last edited by
      #2

      thanks

      1 Reply Last reply
      0
      • A Anonymous

        how do i take A strings data and take all the chars or substrings and store them Array INDividualy... so say if the data in the string is HELLO THERE take H and store it to index 0 E store it to index 1 and so on and so forth even the space between HELLO and THERE.

        C Offline
        C Offline
        Christian Graus
        wrote on last edited by
        #3

        String has a ToCharArray method. Christian Graus - Microsoft MVP - C++

        1 Reply Last reply
        0
        • A Anonymous

          how do i take A strings data and take all the chars or substrings and store them Array INDividualy... so say if the data in the string is HELLO THERE take H and store it to index 0 E store it to index 1 and so on and so forth even the space between HELLO and THERE.

          S Offline
          S Offline
          Scott Page
          wrote on last edited by
          #4

          Strings have a "Chars" property array, which is the string split into an array of characters, just like what you are wanting. For Example. Dim S As String = "Test" S.Chars(0) ' contains T S.Chars(1) ' contains e S.Chars(2) ' contains s S.Chars(3) ' contains t You can also use the "ToCharArray" function of a String to get a specific substring of the string and split it into a character array. For Example. Dim S As String = "Test" S.ToCharArray(2, 2) ' returns "st" because s is the the third index 'of "Test" (zero based array) and the length of the returned array (second 'parameter of the ToCharArray function) is 2. Hope this helps, Scott "Some people spend an entire lifetime wondering if they made a difference. The Marines don't have that problem." ( President Ronald Reagan)

          A 1 Reply Last reply
          0
          • S Scott Page

            Strings have a "Chars" property array, which is the string split into an array of characters, just like what you are wanting. For Example. Dim S As String = "Test" S.Chars(0) ' contains T S.Chars(1) ' contains e S.Chars(2) ' contains s S.Chars(3) ' contains t You can also use the "ToCharArray" function of a String to get a specific substring of the string and split it into a character array. For Example. Dim S As String = "Test" S.ToCharArray(2, 2) ' returns "st" because s is the the third index 'of "Test" (zero based array) and the length of the returned array (second 'parameter of the ToCharArray function) is 2. Hope this helps, Scott "Some people spend an entire lifetime wondering if they made a difference. The Marines don't have that problem." ( President Ronald Reagan)

            A Offline
            A Offline
            Anonymous
            wrote on last edited by
            #5

            yes this helps a bunch. so say if i wanted to do a loop that will stop as soon as i completed storing the chars in the array. Dim S As String S = "hello there" Dim I As Integer Dim Chars() as String I = 0; For i To S.Legnth Step +1 // don't know yet how i set that up S.Chars(0); Next do whateever... i don't know how am i attemping this, loops are still fuzzy to me but I have some grasp. -thanks George

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups