Wrox Home  
Search P2P Archive for: Go

  Return to Index  

pro_vb thread: filesystemobject


Message #1 by Greg Partin <GPartin@c...> on Thu, 29 Nov 2001 15:41:07 -0500
Greg,

Yes, I forgot to mention that you must set reference to:

"Microsoft Scripting Runtime"

Below is a working example of the FSO that I currently use:

Sub BigFile()
   Dim fso As New FileSystemObject
   Dim tsIn As TextStream
   Dim tsOut As TextStream
   Dim x As String
   Dim vName As Variant
   Dim lCount As Long
   Dim z
   Dim LineOut As String
      
   Set tsIn = fso.OpenTextFile("C:\fileIn.TXT", ForReading)
   Set tsOut = fso.CreateTextFile("C:\fileOut.CSV")
   
   Do While Not tsIn.AtEndOfStream
      x = tsIn.ReadLine
      
      vName = Split(x, ",")
     'lCount = UBound(vName)
      
      LineOut = ""
      For z = 0 To 99
         LineOut = LineOut & vName(z) & ","
      Next z
      LineOut = Left(LineOut, Len(LineOut) - 1)
      tsOut.WriteLine (LineOut)
            
   Loop

   MsgBox "CSV file has been created...Press any key"

   Set tsIn = Nothing
   Set tsOut = Nothing
   Set fso = Nothing
   

End Sub

Regards,

Walt




  Return to Index