A System.Windows.Forms.HtmlDocument (in VB.NET) is not an mshtml.HtmlDocument (in VBA). Without seeing the relevant code, I can't be sure that you haven't ended up with the former.
Rather than going through extra steps to get the latter, you can write your own method for getting elements with a particular class name, e.g.
Public Class Form1
Dim wb As WebBrowser
Function GetElementsHavingClassName(doc As HtmlDocument, className As String) As List(Of HtmlElement)
Dim elems As New List(Of HtmlElement)
For Each elem As HtmlElement In doc.All
Dim classes = elem.GetAttribute("className")
If classes.Split(" "c).Any(Function(c) c = className) Then
elems.Add(elem)
End If
Next
Return elems
End Function
Sub ExtractElements(sender As Object, e As WebBrowserDocumentCompletedEventArgs)
Dim wb = DirectCast(sender, WebBrowser)
Dim flintstones = GetElementsHavingClassName(wb.Document, "flintstone")
If flintstones.Count > 0 Then
For Each fs In flintstones
' do something with the element
TextBox1.AppendText(fs.InnerText & vbCrLf)
Next
Else
TextBox1.Text = "Not found."
End If
End Sub
Sub DoStuff()
If wb Is Nothing Then
wb = New WebBrowser
End If
RemoveHandler wb.DocumentCompleted, AddressOf ExtractElements ' don't leave any old ones lying around
AddHandler wb.DocumentCompleted, AddressOf ExtractElements
Dim loc = "file:///c:\temp\somehtml.html"
Try
wb.Navigate(loc)
Catch ex As Exception
'TODO: handle the problem gracefully.
MsgBox(ex.Message)
End Try
End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
DoStuff()
End Sub
Private Sub Form1_FormClosing(sender As Object, e As FormClosingEventArgs) Handles MyBase.FormClosing
If wb IsNot Nothing Then
RemoveHandler wb.DocumentCompleted, AddressOf ExtractElements
wb.Dispose()
End If
End Sub
End Class
Which, given the HTML
<!DOCTYPE html>
<html>
<head><title></title></head>
<body>
<div class="fred flintstone">Fred</div>
<div class="wilma flintstone">Wilma</div>
<div class="not-a-flintstone">Barney</div>
</body>
</html>
outputs
Fred
Wilma