Re: Identify Delimiters
- From: Chuck Grimsby <c.grimsby@xxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Fri, 19 Oct 2007 18:29:05 -0500
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!
.
- Follow-Ups:
- Re: Identify Delimiters
- From: CDMAPoster
- Re: Identify Delimiters
- References:
- Identify Delimiters
- From: Roy
- Identify Delimiters
- Prev by Date: Re: It would be nice if MS did this
- Next by Date: Re: Migrating away from MS-Access
- Previous by thread: Re: Identify Delimiters
- Next by thread: Re: Identify Delimiters
- Index(es):
Relevant Pages
|