程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 更多編程語言 >> 編程綜合問答 >> vb6.0-VB6.0 webBrowser寫入HTML語言並將Recordset返回為HTML表格

vb6.0-VB6.0 webBrowser寫入HTML語言並將Recordset返回為HTML表格

編輯:編程綜合問答
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

最佳回答:


後來將函數的雞腿內容加在字符串中解決問題

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved