Re: Identify Delimiters




Will the file *always* have a known number of "fields" in it?

If so, use the split function to find out if it has the right amount
of fields. Try it once with vbTab, then (if that returns the wrong
number of fields) try the semi-colon.

Public Function CountFields(strIn As String, _
strDelimiter As String) _
As Long
Dim varFields As Variant

varFields = Split(strIn, strDelimiter)
CountFields = UBound(varFields)
End Function



On Tue, 16 Oct 2007 13:45:36 -0700, Roy <praish1998@xxxxxxxxx> wrote:
I use a A2003 App.I get a text file everyday from a external source
which I use to update my tables.The problem is there is no consistent
delimiter used in this text file.Some days it is tab or other days it
uses semi-colon(;) as a delimiter.
So in my line input code I use both the codes and commenting either
one when the import fails.

Open TestFile For Input As #1
Do While Not EOF(1)
Line Input #1, str1
'str2 = Split(str1, vbTab)--the days when tab is used
str2 = Split(str1, ";"))--the days when semi-colonis used

How to identify the delimiter so that I can use a If statement to
chose one?

Please Post Any Replies To This Message Back To the Newsgroup.
There are "Lurkers" around who can benefit by our exchange!
.



Relevant Pages

  • Re: Identify Delimiters
    ... delimiter used in this text file.Some days it is tab or other days it ... uses semi-colon(;) as a delimiter. ... So in my line input code I use both the codes and commenting either ...
    (comp.databases.ms-access)
  • Identify Delimiters
    ... which I use to update my tables.The problem is there is no consistent ... delimiter used in this text file.Some days it is tab or other days it ... uses semi-colonas a delimiter. ... So in my line input code I use both the codes and commenting either ...
    (comp.databases.ms-access)
  • Re: Importing text files saved from word forms
    ... the Split function (once for each delimiter) to break the row into the ... Dim strFile As String ... Any way to import many text files into either Excel or Access? ...
    (microsoft.public.access.externaldata)
  • Re: Importing text files saved from word forms
    ... the Split function (once for each delimiter) to break the row into the ... Dim strFile As String ... Doug Steele, Microsoft Access MVP ...
    (microsoft.public.access.externaldata)
  • Re: Parsing tab-delimited records from a sequential file
    ... around in the Help screens for a while and never found the Split function. ... > the string using the Tab delimiter. ... >> Note the second record has data in all fields. ...
    (microsoft.public.access.forms)