我的代码问题令我恼火。
我需要找到一种方法来初始化HTMLDocument对象的Body属性。
Dim helpContent As XmlDocument
Sub LoadDocument()
Dim sectionNode As Xml.XmlNode
Dim HtmlDoc As HtmlDocument = Nothing
Dim details As String
' The WebBrowser1.Document is loaded from an XML document in Resources
HtmlDoc = WebBrowser1.Document
sectionNode = helpContent.SelectSingleNode("//TitlePage")
lblSectionHeader.Text = IIf(title Is Nothing, "Title Page", title)
Dim detailsNode As Xml.XmlNode
detailsNode = sectionNode.SelectSingleNode("ContentDetails")
details = detailsNode.InnerText
details = Replace(details, "[HELPPATH]", G.HelpPath)
HtmlDoc.Body.InnerHtml = details
此时Body没有,并且分配失败,错误91 “对象变量或块变量未设置”
WebBrowser1.DocumentText = HtmlDoc.Body.InnerHtml
End Sub
如果我重复循环两次并完成错误记录程序,则会突然分配主体。
我试过找到一种初始化Body对象的方法,但它是ReadOnly
有谁知道我可以阻止这种情况发生的方式?