Not able to remove blank spaces from string

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • SwapnilD
    New Member
    • Jan 2010
    • 41

    Not able to remove blank spaces from string

    I'm implementing a feature which reads comma separated txt file from server(one line at a time).

    Format of file is fixed, There are 3 columns on each row.

    After reading the row from file I insert it in a database table.

    But first value of each row aoutomatically appends two blank spaces, even if there are no blank spaces at the begining of each row.

    I tried to use "TRIM/LTRIM/Replace" to remove blank spece from the first value of each row, but didn't succeed.

    I even tried to use trim in stored procedure itself.

    Can you please provide me a work around to remove blank spaces in this scenario.

    Thanks in advance
  • Joseph Martell
    Recognized Expert New Member
    • Jan 2010
    • 198

    #2
    Check how you are using your Trim function. The Trim function does not modify the string you call it on. For example:

    Code:
    Dim aString As String = "   Example of String  _   "
    aString.Trim()    'does not modify value of aString
    In order to get the Trim to stick, you have to assign the result of the Trim() operation:

    Code:
    aString = aString.Trim()
    If this doesn't work, post your code as you are currently using it so we can see exactly what isn't working.

    Comment

    • SwapnilD
      New Member
      • Jan 2010
      • 41

      #3
      Dear Joseph,

      Thanks for your reply.

      I solved it, Actually, I was using VbCrlf after each row, this was causing the issue, I have removed VbCrlf and I am not having blank spaces after each row.

      Thanks again.

      Swapnil

      Comment

      Working...