same as above uses split to build the array
but reads the complete file and not line by line
as the above with line input is only reading one
line and then creating the array.It will continually
overwrite itself.
[code]
'your file must be amended to add :: after each name
George::John::Megan::
Bridget::Mike::Chris::
'
saved as C:\my documents\mytext.txt
'read the complete file instead of line by line
'faster and cleaner
Option Explicit
Private Sub Command1_Click()
Dim sResult as variant 'must be variant
Dim myVar as string
Dim sfile As String, intNum As Integer
intNum = FreeFile
sfile = "C:\my Documents\myfile.txt"
Open sfile For Input As intNum
myVar = StrConv(InputB(LOF(intNum), intNum), vbUnicode)
Close intNum
'
sResult = Split(myVar,"::")
'you now have an array sResult
'
'to check it out
Dim i as Integer
For i = lbound(sResult) to (uBound(sResult)- 1)
Msgbox sResult(i)
Next i
'
End Sub
[/code}
[Edited by HeSaidJoe on 09-10-2000 at 03:43 PM]




Reply With Quote