Hi guys,

 

Just my 2 cents.

 

I use ADO often when I need to read a csv file.

Would it be possible for you to use csv? Then your csv records are
brought into an ado.recordset which is nice an handy.

I can send you sample code of what I have done.

 

Ramon

 

________________________________

From: Don Roberts [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, February 23, 2005 8:04 AM
To: [email protected]
Subject: Re: [vbhelp] Re: Re-inventing the Wheel

 

Chris, try this out on your file. This code replaces "," with "|" (a
pipe with quotes) so that it can be easily converted to an array. You
may have to make some modifications to save each line to an array:

    Dim SEARCH_STRING As String     'String we don't want
    Dim REPLACE_STRING As String    'New string
    Dim strLineInput As String      'input string from file
    Dim strFileName As String       'file name
    
    Dim intOpenNumber As Integer      'FreeFile number
    
    strFileName = "C:\test.txt"    'TODO: get the file name and set it
here
    
    SEARCH_STRING = Chr(34) & "," & Chr(34)     'find ","
    REPLACE_STRING = Chr(34) & "|" & Chr(34)    'replace with "|"
    
    intOpenNumber = FreeFile
    
    Open fileName For Input As #intOpenNumber
        
        Do While Not EOF(intOpenNumber)
            
            Line Input #intOpenNumber, strLineInput
                
                Debug.Print ("Before conversion: " & strLineInput)
            
            strLineInput = Replace(strLineInput, SEARCH_STRING,
REPLACE_STRING)
                
                Debug.Print ("After conversion: " & strLineInput)
            
            'TODO: code here to do work on the modified string i.e.,
            'make an array using the pipe to split the input line, etc.
            
        Loop
        
    Close #intOpenNumber


On Tue, 22 Feb 2005 20:43:11 -0000, HouseDad <[EMAIL PROTECTED]>
wrote:
> 
> 
> --- In [email protected], "Ian Brooke" <[EMAIL PROTECTED]> wrote:
> > Hi,
> > The Line Input #n,aString command will read an entire line (as long
> as it's terminated by a CR/LF) even if it has commas in it.
> >
> > Ian
> 
>     Yes indeed, and I use it quite a bit.  Unfortunately, it doesn't
> help me much when there are commas in the middle of the field.
> Unless, of course, there is a way to use SPLIT to read the line into
> an array, without those pesky commas in the middle of the field
> screwing the fields up.
> 
>     The only thing I have found so far is one guy said if you set a
> type up then input them all in the same line (ie input #1,a$,b$,C$)
> and delimit them without commas (ie "field 1""field2""field3") that
> it would ignore all the commas that way, but haven't tried that yet,
> and I don't think it's correct, judging from his example that was
> posted.  I could erase the commas in an incoming files I guess (if
> there's quotes on either side of the comma then delete it), but I
> would like to get around that if possible.
> 
> [C]
> 
> '// =======================================================
>    Rules : http://ReliableAnswers.com/List/Rules.asp
>    Home  : http://groups.yahoo.com/group/vbHelp/
>    =======================================================
>    Post  : [email protected]
>    Join  : [EMAIL PROTECTED]
>    Leave : [EMAIL PROTECTED]
> '// =======================================================
> 
> Yahoo! Groups Links
> 
> 
> 
> 
> 


-- 
---
Don Roberts - [EMAIL PROTECTED]
http://www.drscripting.com
http://www.freakingidiot.com



'// =======================================================
    Rules : http://ReliableAnswers.com/List/Rules.asp
    Home  : http://groups.yahoo.com/group/vbHelp/
    =======================================================
    Post  : [email protected]
    Join  : [EMAIL PROTECTED]
    Leave : [EMAIL PROTECTED]
'// =======================================================






Yahoo! Groups Sponsor

 
<http://us.ard.yahoo.com/SIG=129l203ta/M=324658.6070095.7083352.3001176/
D=groups/S=1705115364:HM/EXP=1109255462/A=2343726/R=0/SIG=12ipi3dvd/*htt
p:/clk.atdmt.com/VON/go/yhxxxvon01900091von/direct/01/&time=110916906214
1091>
<http://us.ard.yahoo.com/SIG=129l203ta/M=324658.6070095.7083352.3001176/
D=groups/S=1705115364:HM/EXP=1109255462/A=2343726/R=1/SIG=12ipi3dvd/*htt
p:/clk.atdmt.com/VON/go/yhxxxvon01900091von/direct/01/&time=110916906214
1091> 

Get unlimited calls to
<http://us.ard.yahoo.com/SIG=129l203ta/M=324658.6070095.7083352.3001176/
D=groups/S=1705115364:HM/EXP=1109255462/A=2343726/R=1/SIG=12ipi3dvd/*htt
p:/clk.atdmt.com/VON/go/yhxxxvon01900091von/direct/01/&time=110916906214
1091> 

U.S./Canada
<http://us.ard.yahoo.com/SIG=129l203ta/M=324658.6070095.7083352.3001176/
D=groups/S=1705115364:HM/EXP=1109255462/A=2343726/R=1/SIG=12ipi3dvd/*htt
p:/clk.atdmt.com/VON/go/yhxxxvon01900091von/direct/01/&time=110916906214
1091> 

 
<http://view.atdmt.com/VON/view/yhxxxvon01900091von/direct/01/&time=1109
169062141091> 

 
<http://us.adserver.yahoo.com/l?M=324658.6070095.7083352.3001176/D=group
s/S=:HM/A=2343726/rand=437179251> 

 

________________________________

Yahoo! Groups Links

*       To visit your group on the web, go to:
        http://groups.yahoo.com/group/vbhelp/
          
*       To unsubscribe from this group, send an email to:
        [EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]> 
          
*       Your use of Yahoo! Groups is subject to the Yahoo! Terms of
Service <http://docs.yahoo.com/info/terms/> . 



[Non-text portions of this message have been removed]




'// =======================================================
    Rules : http://ReliableAnswers.com/List/Rules.asp
    Home  : http://groups.yahoo.com/group/vbHelp/
    =======================================================
    Post  : [email protected]
    Join  : [EMAIL PROTECTED]
    Leave : [EMAIL PROTECTED]
'// =======================================================
 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/vbhelp/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



Reply via email to