I have a text file that I would like to loop through and obtain a listing of vendors. It is a file that is seperated by the "^" simble. I would like to loop through it and place the results in a combo box. Here is the code I have so far:
Function getVendors(offnum)
Const ForReading = 1
Const Create = False
' Declare local variables
strFileName = Server.MapPath("vendors.txt")
' Instantiate the FileSystemObject
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
' use Opentextfile Method to Open the text File
Set TS = objFSO.OpenTextFile(strFileName, ForReading, Create)
strValue = Ts.Readline
strArray = Split(strValue, "^")
' - strArray is now an array
Dim i
If Not TS.AtEndOfStream Then
For i = 0 to Ubound(strArray)
'Response.Write i & " = " & strArray(i) & "<BR>"
VendorName = strArray(0)
VendorAddr = strArray(1)
VendorCity = strArray(2)
VendorState = strArray(3)
VendorZip = strArray(4)
VendorID = strArray(5)
VendorOff = strArray(6)
Next
End IF
' close TextStreamObject
' and destroy local variables to relase memory
'TS.Close
'Set TS = Nothing
'Set objFSO = Nothing
End Function
This is how I am calling it:
<option value="002"><%If Not TS.AtEndOfStream Then %><%=VendorName%>,<%=VendorAddr%> <%=VendorCity%>,<%=vendorzip%><%END IF%></option>
The problem is that is only goes through the first line, then it stops. It places the first line in the combo box but that is it. How can I get all of them in there, also can you sort with a text file?