Trim() does not work with Tab charachters

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi everyone.
I have an Access application that works with text files. Importing
information into tables from text document. Basicaly I open a delimited file
and read filed by field into access table. during each run I use the
fucnction Trim() to get rid of extra spaces. If the file contains tabs
instead of spaces the trim() does not work.
Can anyone help?
Thank you.
 
Well, you COULD use INSTR to see if there are any Tabs, and then spin through
the string and remove them.
 
The VBA Replace function would be easier.

Here is an example (with your trim problem), it replaces all tabs with
spaces and the tabs before or after the string will be stripped by the Trim

Dim str As String

str = vbTab & "john" & vbTab & vbTab
Debug.Print "["; str; "]"

str = Trim(str)
Debug.Print "["; str; "]"

str = Trim(Replace(str, vbTab, " "))
Debug.Print "["; str; "]"

John... Visio MVP
 
Back
Top