窗體裡添加webBrowser1 (在部件裡添加Microsoft internet control)和 Command1控件。 運用以下的函數將 Adodc1.Recordset 返回到HTML表格中,為什麼實現不了啊?哪位高手支支招???
Private Sub Command1_Click()
Dim strHtml As String
strHtml = "<html>" & vbCrLf
strHtml = strHtml & "<head>" & vbCrLf
strHtml = strHtml & "</head>" & vbCrLf
strHtml = strHtml & "<h1 align='center'>報告單</h1>" & vbCrLf
strHtml = strHtml & "<body>" & vbCrLf
strHtml = strHtml & ReturnHTMLTable(Adodc1)
strHtml = strHtml & "<li>" & vbCrLf
strHtml = strHtml & "Hello" & vbCrLf
strHtml = strHtml & "<input type='button' name='Submit22' value=' 打印此頁 ' onClick='javascript:print();'>" & vbCrLf
strHtml = strHtml & "</li>" & vbCrLf
strHtml = strHtml & "</body>" & vbCrLf
strHtml = strHtml & "</html>" & vbCrLf
WebBrowser1.Document.body.innerHTML = strHtml
End Sub
Private Sub Form_Load()
WebBrowser1.Navigate2 "about:blank"
End Sub
-----------------------------------------------------------------------
Function ReturnHTMLTable(tmpAdodc)
Set rs = tmpAdodc.Recordset
rs.MoveFirst
response.Write "<table class=""data"" cols=""" & rs.Fields.Count & """>"
response.Write "<tr>"
For Each oField In rs.Fields
response.Write "<th>" & oField.Name & "</th>"
Next
response.Write "</tr>"
Do While Not rs.EOF
response.Write "<tr>"
For Each oField In rs.Fields
response.Write "<td>"
If IsNull(oField) Then
response.Write " "
Else
response.Write oField.Value
End If
response.Write "</td>"
Next
rs.MoveNext
response.Write "</tr>"
Loop
response.Write "</table>"
End Function
後來將函數的雞腿內容加在字符串中解決問題