用VB把数据库文件转换成Htm1格式 周勇生 2001年 13期 我们在使用DAO对象存取DBF库时,应在“工程/引用”中选取“Microsoft Dao 2.5/3.51 Compatibility Library”而不使用“Microsoft Dao 3.51 Library”,这样才能够顺利存取DBF库。本程序可剪切在表单中的From_load()中. Dim db As DAO.Database Dim rs As DAO.Recordset Dim i As Integer Dim fso As New FileSystemObject Private Sub Form_Load() Set db = OpenDatabase(“d:\vb98\gz9910”,False,False,“FoxPro 2.5;”) Set rs = db.OpenRecordset(“rsda”) Set fso = CreateObject(“scripting.filesystemobject”) If fso.FileExists(App.Path & “\test.htm”) Then fso.DeleteFile (App.Path & “\test.htm”) End If fd = FreeFile Open “test.htm” For Append Access Write As #fd rs.MoveFirst Print #fd, “” Print #fd, “
” Print #fd, “XX公司1999年10月工资发放表”
Print #fd, “”
Print #fd, “ < tr >”
Print #fd, “ < td width=5% align=center > 工号 < /font >< /td>”
Print #fd, “ < td width=8% align=center > 姓名 < /strong >< /td>”
Print #fd, “ < td width=10% align=center > 部门 < /font >< /td>”
Print #fd, “ < td width=10% align=center > 职位 < /font >< /td>”
Print #fd, “ < td width=10% align=center > 籍贯 < /font >< /td>”
Print #fd, “ < td width=10% align=center > 家庭住址 < /font > ”
Print #fd, “ < td width=10% align=center > 联系电话 < /font > ”
Print #fd, “ < td width=10% align=center > 爱好 < /font > ”
Print #fd, “ < td width=26% align=center > 简历 < /font > ”
Print #fd, “< /tr >”
rs.MoveFirst
do while not rs.eof()
Print #fd, “< tr >”
Print #fd, “
” & rs.Fields(“gh”) & “ ”
Print #fd, “ ” & rs.Fields(“xm”) & “ ”
Print #fd, “ ” & rs.Fields(“bm”) & ““/td”
Print #fd, “ ” & rs.Fields(“zw”) & “ ”
Print #fd, “ ” & rs.Fields(“jg”) & “ ”
Print #fd, “ ” & rs.Fields(“dz”) & “ ”
Print #fd, “ ” & rs.Fields(“tele”) & “ ”
Print #fd, “ ” & rs.Fields(“ah”)& “ ”
Print #fd, “ ” & rs.Fields(“jl”) & “ ”
Print #fd, “”
rs.MoveNext
loop
Close #fd
End Sub