vb中如何将记录集中记录导出存为HTML和TEXT格式??

cjwcyc 2003-03-17 03:43:59
vb中如何将记录集中记录导出存为HTML和TEXT格式??
...全文
25 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
xsp 2003-03-17
  • 打赏
  • 举报
回复
dim fn as string
dim i as long

fn="c;\abc.txt"
open fn for output as #1
rec.movefirst
for i=1 to rec.recordercount
print #1,rec."字段名1",rec."字段名2",...,rec."字段名n"
rec.movenext
next i
close #1
Cooly 2003-03-17
  • 打赏
  • 举报
回复
text的比较简单,html你要自己转换格式了。
open "c:\rec.txt" for output as #1
do until rs.eof
print #1,字段一,字段二,字段三,字段四.......
rs.movenext
loop
close #1

html格式,多了一些
<html>
<head><title></title></head>
<body>
内容
</body>
</html>
当然,如果你不需要这些也无所谓,但如果你想要效果好一些,至少要有Table

还用刚才的例子
open "c:\rec.txt" for output as #1
print #,"<html>"
print #,"<head>"
print #,"<title>例子</title>"
print #,"</head>"
print #,"<body>"
print #,"<table border=1 cellpadding=1 cellspacing=1 align=center width=100%>"


do until rs.eof
print #1,"<tr>"
for i=0 to rs.fields.count-1
print #1,"<td>" & rs(i) & "</td>"
next
print #1,"</tr>"
rs.movenext
loop

print #,"</table>"

print #,"</body>"
print #,"</html>"
close #1


xsp 2003-03-17
  • 打赏
  • 举报
回复
记录集都取到了,剩下的就是对文本文件的操作了,只是文件名不同而已。

7,764

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧