Results 1 to 6 of 6

Thread: Removing leading space from string after Split Command

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Apr 2001
    Location
    The Netherlands
    Posts
    94
    The string doesn't trim, i have to remove the leading spaces on all the lines except the first one which doesn't have one.




    Code:
    
    Dim t() As String
    Dim x As Integer
    
    t = Split(ls, vbCrLf)
    
    
    For x = 0 To UBound(t)
    Trim (t(x))
        
    
      posi(1) = 1         'position cursor is on 2nd letter
    
        For k = 1 To 17     ' make spaces array
        
        l = InStr(posi(k), t(x), " ", vbTextCompare)

    I know that the split command doesn't return strings but array but how can i remove those leading spaces ?
    "Against All Odds"

  2. #2
    Matthew Gates
    Guest
    Have you tried the Left or Mid functions to basically trim the spaces?

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Apr 2001
    Location
    The Netherlands
    Posts
    94
    If you are talking about LTrim, yes i've tried that. It won't work.
    I even tried Trim(Cstr(t(x)))

    No luck.
    "Against All Odds"

  4. #4
    Matthew Gates
    Guest
    What is ls? Can I see the all/some more of the code you have?

  5. #5
    Hyperactive Member
    Join Date
    Apr 2001
    Posts
    315
    Trim is a Function, not a Sub.
    Try
    t(x) = Trim(t(x))

  6. #6

    Thread Starter
    Lively Member
    Join Date
    Apr 2001
    Location
    The Netherlands
    Posts
    94
    Thanx John , you were right.

    And ls is just a reference to a string.
    "Against All Odds"

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width