lujame2015
2015-10-14 02:46
采纳率: 33.3%
浏览 2.2k
已采纳

VB6.0 webBrowser写入HTML语言并将Recordset返回为HTML表格

窗体里添加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

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

3条回答 默认 最新

相关推荐 更多相似问题