Title: Read contents from text file dynamically in classic asp
I have done the code to write the values I enter in the text box to a text file. Now I want to read those values and assign it to a variable.
The values stored in text file are as follows:
abc.jpg,www.google.com
123.jpg, www.yahoo.com
I want to read the image name in a separate variable and the link in separate variable. As I want to assign those to image rotator code. Please help.
I have used the following code to read the link in the text file: now I want to read the image name from the text file.
Do While Not objTextFile.AtEndOfStream
intLineNumber = intLineNumber + 1
strReadLineText = objTextFile.ReadLine
'response.Write("Hi")
Postion1= InStr(strReadLineText, strSearchText)
Postion2= Postion1 + len(strSearchText)
URLString=Mid(strReadLineText,Postion2+1,len(strReadLineText))
'URLString=Left(strReadLineText,strSearchText)
If strSearchText <> "" And InSt开发者_高级运维r(strReadLineText, strSearchText) > 0 Then
strReadLineText = Replace(strReadLineText, _
strSearchText, _
"<span style=""background-color:yellow;"">" & strSearchText & "</span>")
strLineNumbers = strLineNumbers & intLineNumber & ", "
Exit Do
Instead of using InStr
, you could use a Split
(DevGuru link) which will return an array of the values on each line.
arrVals = Split(strReadLineText, ",")
strImageName = Trim(arrVals(0))
URLString = Trim(arrVals(1))
精彩评论