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

format strings

Scheduled Pinned Locked Moved Visual Basic
6 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.
  • M Offline
    M Offline
    Marc Soleda
    wrote on last edited by
    #1

    Hi all, I have a string (for example itcontains "abcde"). I'd like to fill it with spaces until a determined length (for ex. 10) so the final string would be "abcde " How can I do it? Thanks in advance, Marc Soleda

    ... she said you are the perfect stranger she said baby let's keep it like this... Dire Straits

    J M 2 Replies Last reply
    0
    • M Marc Soleda

      Hi all, I have a string (for example itcontains "abcde"). I'd like to fill it with spaces until a determined length (for ex. 10) so the final string would be "abcde " How can I do it? Thanks in advance, Marc Soleda

      ... she said you are the perfect stranger she said baby let's keep it like this... Dire Straits

      J Offline
      J Offline
      JUNEYT
      wrote on last edited by
      #2

      Marc Soleda wrote:

      final string would be

      Dim StrLength as Int32  = 10
      Dim myString = "abcde"
      Dim addSpace as Int32  = 10 - myString.length
      Dim I as Int32
          For I = 1 to addspace
              mystring = mystring + " "
          next 
      

      :wtf:

      What a curious mind needs to discover knowledge is noting else than a pin-hole.

      M 1 Reply Last reply
      0
      • M Marc Soleda

        Hi all, I have a string (for example itcontains "abcde"). I'd like to fill it with spaces until a determined length (for ex. 10) so the final string would be "abcde " How can I do it? Thanks in advance, Marc Soleda

        ... she said you are the perfect stranger she said baby let's keep it like this... Dire Straits

        M Offline
        M Offline
        Marcus J Smith
        wrote on last edited by
        #3

        strABCDE.PadRight(10)

        That will take into account the length that already exists and then add the number of spaces or characters in order to finish filling to the required length.


        CleaKO

        "I think you'll be okay here, they have a thin candy shell. 'Surprised you didn't know that." - Tommy Boy
        "Fill it up again! Fill it up again! Once it hits your lips, it's so good!" - Frank the Tank (Old School)

        M 1 Reply Last reply
        0
        • J JUNEYT

          Marc Soleda wrote:

          final string would be

          Dim StrLength as Int32  = 10
          Dim myString = "abcde"
          Dim addSpace as Int32  = 10 - myString.length
          Dim I as Int32
              For I = 1 to addspace
                  mystring = mystring + " "
              next 
          

          :wtf:

          What a curious mind needs to discover knowledge is noting else than a pin-hole.

          M Offline
          M Offline
          Marc Soleda
          wrote on last edited by
          #4

          sorry, I missed to tell that I'm looking for a Framework function . For example: I've done the same but filling it with "0" with the "Format" method but with spaces I can't do it. Is there something similar with spaces? Marc

          ... she said you are the perfect stranger she said baby let's keep it like this... Dire Straits

          M 1 Reply Last reply
          0
          • M Marc Soleda

            sorry, I missed to tell that I'm looking for a Framework function . For example: I've done the same but filling it with "0" with the "Format" method but with spaces I can't do it. Is there something similar with spaces? Marc

            ... she said you are the perfect stranger she said baby let's keep it like this... Dire Straits

            M Offline
            M Offline
            Marcus J Smith
            wrote on last edited by
            #5

            Format() is a VB6 function and for the padding function there is now a .PadLeft and a .PadRight().


            CleaKO

            "I think you'll be okay here, they have a thin candy shell. 'Surprised you didn't know that." - Tommy Boy
            "Fill it up again! Fill it up again! Once it hits your lips, it's so good!" - Frank the Tank (Old School)

            1 Reply Last reply
            0
            • M Marcus J Smith

              strABCDE.PadRight(10)

              That will take into account the length that already exists and then add the number of spaces or characters in order to finish filling to the required length.


              CleaKO

              "I think you'll be okay here, they have a thin candy shell. 'Surprised you didn't know that." - Tommy Boy
              "Fill it up again! Fill it up again! Once it hits your lips, it's so good!" - Frank the Tank (Old School)

              M Offline
              M Offline
              Marc Soleda
              wrote on last edited by
              #6

              Great !! That's exactly what I was looking for. thanks, Marc.

              ... she said you are the perfect stranger she said baby let's keep it like this... Dire Straits

              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