Board logo

标题: VBS如何逐行读取指定文件中的每一张图片并循环显示? [打印本页]

作者: yywd    时间: 2008-6-4 19:41     标题: VBS如何逐行读取指定文件中的每一张图片并循环显示?

逐行读取d:\0.txt循环显示0.txt中的每一张图片
<script language="vbscript"><!--
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("d:\0.txt", 1)
Do Until objFile.AtEndOfStream
tmpArray = objFile.ReadLine
For i = 0 to UBound(tmpArray)
Response.Write("<img src="tmpArray"><br>"))
'Next
'end  
rs.MoveNext
Loop
'end if
objFile.Close
Set rs = Nothing
--></script>

哪里错了, 无法显示,更别说循环
作者: zqz0012005    时间: 2008-9-20 18:08

数组不是这么用的啊
  1. dim tmpArray()
  2. i = 0
  3. Set objFSO = CreateObject("Scripting.FileSystemObject")
  4. Set objFile = objFSO.OpenTextFile("d:\0.txt", 1)
  5. Do Until objFile.AtEndOfStream
  6. tmpArray(i) = objFile.ReadLine
  7. i = i + 1
  8. loop
  9. For i = 0 to UBound(tmpArray)
  10. Response.Write("<img src='" & tmpArray(i) & "'>
  11. ")
  12. next
复制代码
达到你的目的其实用不着数组
  1. Set objFSO = CreateObject("Scripting.FileSystemObject")
  2. Set objFile = objFSO.OpenTextFile("d:\0.txt", 1)
  3. Do Until objFile.AtEndOfStream
  4. Response.Write("<img src='" & objFile.ReadLine & "'>
  5. ")
  6. loop
复制代码

作者: hbwhyin    时间: 2010-3-16 04:59

版主,我用你的怎么出错啦




欢迎光临 批处理之家 (http://bathome.net./) Powered by Discuz! 7.2