Changing the length of a string at runtime

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • chezz
    New Member
    • Jun 2007
    • 13

    Changing the length of a string at runtime

    Hey I'm a Newb and i do software at school, im currently working on a vb 6.0 remote connection program. I need to change the length of a string at runtime, i'v already looked at redim for arrays, or using another string but i cant dimesion it with a variable.

    Example i need to do this
    Code:
    dim a as string * variable
    or to some how redim.

    any help with this or an alternate method would be much appreciated thanks.
  • Dököll
    Recognized Expert Top Contributor
    • Nov 2006
    • 2379

    #2
    Originally posted by chezz
    Hey I'm a Newb and i do software at school, im currently working on a vb 6.0 remote connection program. I need to change the length of a string at runtime, i'v already looked at redim for arrays, or using another string but i cant dimesion it with a variable.

    Example i need to do this
    Code:
    dim a as string * variable
    or to some how redim.

    any help with this or an alternate method would be much appreciated thanks.
    Hello, chezz!

    If you have not already searched here, I would suggest you do. Answers to this have been already added.

    Please give that a whirl or stay tuned.

    In a bit!

    Comment

    • Killer42
      Recognized Expert Expert
      • Oct 2006
      • 8429

      #3
      I think it's fair to say that if you define a fixed-length string in VB, the length is fixed - hence the name. Hint: this is not the only type of string.

      Comment

      • chezz
        New Member
        • Jun 2007
        • 13

        #4
        Hey i know that you can leave string undemensioned but im using a specific algorithm (mid$ function) to strip excess spaces out of a string. But don't worry i figured out a way around it. Thx anyway

        Comment

        • Killer42
          Recognized Expert Expert
          • Oct 2006
          • 8429

          #5
          Oh well, glad you got it working, anyway.

          One thing to keep in mind. I'm pretty sure Mid$() function doesn't mind if you go beyond the end of a variable-length string - it just doesn't return anything. So you don't need to worry about crashing because you overran the end, or anything.

          In any case, I'm guessing the Len() function is probably your saviour.

          Comment

          Working...