Umm, this is pretty basic stuff. Just open the File, read it Line by Line,
then Split each Line to get your information. I am not sure, but there may
be a simplier method. You could also use the FileSystemObject but that
requires additional DLLs to be distributed, so here is the lowest level of
VB Code to do the Trick in the Fastest method
Private Sub ReadFile()
Dim sFile As String
Dim sLines() As String, sLine As String, sParams() As String
Dim iFile As Integer
Dim i As Long, j As Long
sFile = App.Path & "\MyTest.txt"
'Open the File
iFile = FreeFile
Open sFile For Binary Access Read As iFile
'Read in the Entire File (reusing the sFile Variable)
sFile = Space(LOF(iFile))
Get iFile, , sFile
'Close the File
Close iFile
'Split the Entire File into Lines
sLines = Split(sFile, vbCrLf)
'Enumerate through the Lines
For i = 0 To UBound(sLines)
'Get the Line Information
sLine = sLines(i)
'Split the Line information to Retrieve the Parameters (using the
Comma as the Separator)
sParams = Split(sLine, ",")
'Debugging Info
'This determines if you are receiving the Right info
For j = 0 To UBound(sParams)
Debug.Print sParams(j)
Next j
Next i
'Clean Up
Erase sLines
Erase sParams
End Sub
-----Original Message-----
From: Jonathan A. Kline [mailto:jonathankl@g...]
Sent: Friday, August 17, 2001 11:25 PM
To: professional vb
Subject: [pro_vb] CSV Input Help
I have a csv file, and I need to input it into a string,
format of file:
number,Full Name, First Name, Last Name,status,username
Basically I am interested in the username field, once i have it
in a string I need to run a system command using it, in this case
detree /y q:\students\username
Anyone have any ideas how to do this? I tried various methoids and
all of them failed... Any help would be greatly appreciated.
Thanx,
Jonathan A. Kline
CCSD, MSOE