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
  1. Home
  2. General Programming
  3. Visual Basic
  4. Grabbing each character of a string, how?

Grabbing each character of a string, how?

Scheduled Pinned Locked Moved Visual Basic
c++tutorialquestion
4 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.
  • S Offline
    S Offline
    ScarberryProd
    wrote on last edited by
    #1

    i have a string and i was wondering how i could grab each character of that string for example in c++ if string="Hello World" then string[3] would return a "l" thank you --------------------- And Like The Wind Our Hero Vanishes Off Into The Distance...

    H J 2 Replies Last reply
    0
    • S ScarberryProd

      i have a string and i was wondering how i could grab each character of that string for example in c++ if string="Hello World" then string[3] would return a "l" thank you --------------------- And Like The Wind Our Hero Vanishes Off Into The Distance...

      H Offline
      H Offline
      Hesham Amin
      wrote on last edited by
      #2

      mid("Hello World",4,1) returns "l" note that in VB6 the first character index is 1 not 0 like C.

      S 1 Reply Last reply
      0
      • H Hesham Amin

        mid("Hello World",4,1) returns "l" note that in VB6 the first character index is 1 not 0 like C.

        S Offline
        S Offline
        ScarberryProd
        wrote on last edited by
        #3

        awsoem thank you --------------------- And Like The Wind Our Hero Vanishes Off Into The Distance...

        1 Reply Last reply
        0
        • S ScarberryProd

          i have a string and i was wondering how i could grab each character of that string for example in c++ if string="Hello World" then string[3] would return a "l" thank you --------------------- And Like The Wind Our Hero Vanishes Off Into The Distance...

          J Offline
          J Offline
          Jeff Varszegi
          wrote on last edited by
          #4

          You can also get them easily using the Chars property:         Dim s As String         Dim i As Integer         s = "one for the toad"         For i = 0 To (s.Length - 1)             Console.WriteLine(s.Chars(i))         Next Note that most of the properties, etc. dealing with arrays in the BCL use zero-based indexing. It can be confusing switching back and forth between zero- and one-based indexing. [EDIT] I misunderstood, and assumed the question was for VB .NET . I apologize. Back to the C# forums for this geek. [/EDIT] Regards, Jeff Varszegi EEEP!  An Extensible Expression Evaluation Package

          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