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

Reverse string

Scheduled Pinned Locked Moved Visual Basic
com
8 Posts 4 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.
  • R Offline
    R Offline
    rprateek
    wrote on last edited by
    #1

    Is there any way we can reverse the string in one command for eg dim str as string str="Hollywood" in one command can we make str="doowylloH"

    Blog for Programmers http://www.rprateek.blogspot.com

    D P T 3 Replies Last reply
    0
    • R rprateek

      Is there any way we can reverse the string in one command for eg dim str as string str="Hollywood" in one command can we make str="doowylloH"

      Blog for Programmers http://www.rprateek.blogspot.com

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      Nope. You're going to have to write your own mdethod to do it. I suggest looking into the StringBuilder class to accomplish this.

      A guide to posting questions on CodeProject[^]
      Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
           2006, 2007, 2008

      R 1 Reply Last reply
      0
      • D Dave Kreskowiak

        Nope. You're going to have to write your own mdethod to do it. I suggest looking into the StringBuilder class to accomplish this.

        A guide to posting questions on CodeProject[^]
        Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
             2006, 2007, 2008

        R Offline
        R Offline
        rprateek
        wrote on last edited by
        #3

        i understand Dave I know how to loop through the string and get it done but i was just asking if any of you who knows the better and short way . Because I was wondering if there would be a function like: string.reverse by .net or any other similar functions. I was just trying to learn some new thing. Thanks for your comment

        Blog for Programmers http://www.rprateek.blogspot.com

        1 Reply Last reply
        0
        • R rprateek

          Is there any way we can reverse the string in one command for eg dim str as string str="Hollywood" in one command can we make str="doowylloH"

          Blog for Programmers http://www.rprateek.blogspot.com

          P Offline
          P Offline
          Paul Conrad
          wrote on last edited by
          #4

          Well, only if you create a method like ReverseString, but you'll still have to code the actual algorithm to reverse the string.

          "The clue train passed his station without stopping." - John Simmons / outlaw programmer "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon "Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham

          R 1 Reply Last reply
          0
          • P Paul Conrad

            Well, only if you create a method like ReverseString, but you'll still have to code the actual algorithm to reverse the string.

            "The clue train passed his station without stopping." - John Simmons / outlaw programmer "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon "Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham

            R Offline
            R Offline
            rprateek
            wrote on last edited by
            #5

            ya that's what i was looking for and also found out from other forums that I can convert the string into chararray() and then do the Array.reverse() thanks Paul

            Blog for Programmers http://www.rprateek.blogspot.com

            P R 2 Replies Last reply
            0
            • R rprateek

              ya that's what i was looking for and also found out from other forums that I can convert the string into chararray() and then do the Array.reverse() thanks Paul

              Blog for Programmers http://www.rprateek.blogspot.com

              P Offline
              P Offline
              Paul Conrad
              wrote on last edited by
              #6

              Cool deal. It's late and been a long day, and I didn't even think of going the array route :-O Glad you found a way to do the string reversal.

              "The clue train passed his station without stopping." - John Simmons / outlaw programmer "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon "Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham

              1 Reply Last reply
              0
              • R rprateek

                ya that's what i was looking for and also found out from other forums that I can convert the string into chararray() and then do the Array.reverse() thanks Paul

                Blog for Programmers http://www.rprateek.blogspot.com

                R Offline
                R Offline
                rprateek
                wrote on last edited by
                #7

                and also for those who are looking for similar answers The VB function StrReverse() can be used by importing the Microsoft.VisualBasic Namespace

                Blog for Programmers http://www.rprateek.blogspot.com

                1 Reply Last reply
                0
                • R rprateek

                  Is there any way we can reverse the string in one command for eg dim str as string str="Hollywood" in one command can we make str="doowylloH"

                  Blog for Programmers http://www.rprateek.blogspot.com

                  T Offline
                  T Offline
                  Thomas Stockwell
                  wrote on last edited by
                  #8

                  CodeProject really doesn't help with obvious homework problems :)

                  Regards, Thomas Stockwell Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. Visit my Blog

                  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