标题:在经典asp中动态读取文本文件内容

发布于 2024-12-07 00:42:01 字数 1006 浏览 0 评论 0原文

我已经完成了将在文本框中输入的值写入文本文件的代码。现在我想读取这些值并将其分配给一个变量。

存储在文本文件中的值如下:

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技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

旧人九事 2024-12-14 00:42:01

您可以使用 SplitDevGuru 链接),它将返回每行上的值的数组。

arrVals = Split(strReadLineText, ",")

strImageName = Trim(arrVals(0))
URLString = Trim(arrVals(1))

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))
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文