标题:在经典asp中动态读取文本文件内容
我已经完成了将在文本框中输入的值写入文本文件的代码。现在我想读取这些值并将其分配给一个变量。
存储在文本文件中的值如下:
abc.jpg,www.google.com
123.jpg, www.yahoo.com
我想读取单独变量中的图像名称和单独变量中的链接。因为我想将它们分配给图像旋转器代码。请帮忙。
我使用以下代码来读取文本文件中的链接:现在我想从文本文件中读取图像名称。
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 InStr(strReadLineText, strSearchText) > 0 Then
strReadLineText = Replace(strReadLineText, _
strSearchText, _
"<span style=""background-color:yellow;"">" & strSearchText & "</span>")
strLineNumbers = strLineNumbers & intLineNumber & ", "
Exit Do
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 InStr(strReadLineText, strSearchText) > 0 Then
strReadLineText = Replace(strReadLineText, _
strSearchText, _
"<span style=""background-color:yellow;"">" & strSearchText & "</span>")
strLineNumbers = strLineNumbers & intLineNumber & ", "
Exit Do
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
![扫码二维码加入Web技术交流群](/public/img/jiaqun_03.jpg)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用
Split
(DevGuru 链接),它将返回每行上的值的数组。Instead of using
InStr
, you could use aSplit
(DevGuru link) which will return an array of the values on each line.