Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 315
  • Last Modified:

Web Browser Component

Hi all

I would like to open a webpage in a VB.net form. I used to be able to drop a Web Control onto VB6 Form and read HTML and submit values to web forms click buttons all in code

Is there web control that I can drop on VB6 form???

cheers

George
0
Geo123
Asked:
Geo123
  • 4
  • 2
  • 2
1 Solution
 
softplusCommented:
0
 
Geo123Author Commented:
I managed to work out that the Microsoft Web Control could be ref in .Net...... but when I try to use same code to expose the HTML its not working the same ie

strHTML = wb.Document.body.innerHTML

Any Ideas??

Thanks for web pages but non are exposing the Web Page HTML to my code/ objects

cheers

George
0
 
SanclerCommented:
George

Add a reference to  Microsoft.mshtml

dim hdoc As mshtml.HTMLDocument - with the scope you want

in your wb_DownloadComplete sub put

hdoc = wb.Document

and you can then access the Web Page HTML through hdoc.

There may be a better way, but that's what I discovered in trying to move from VB (5, in my case) to .NET.

Roger
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
Geo123Author Commented:
ok will give that a go..cheers
0
 
softplusCommented:
How'd it go, George? :)
0
 
Geo123Author Commented:
am still testing added the MSHTML like Sancler said but its not exposing web page html like it does in vb6...pain!!!
0
 
SanclerCommented:
George

In case it helps, here are some code snippets cut and pasted from a working application.  They don't make extensive use of mshtml, but they do show it working in VB.NET.

    Private hdoc As mshtml.HTMLDocument

[...]

    Private Sub wbAct_DownloadComplete(ByVal sender As Object, ByVal e As System.EventArgs) Handles wbAct.DownloadComplete

        hdoc = wbAct.Document
        EnableDocEvents()
        Dim element As Object

        If m_filterText <> "" Then
            txtSearch.Text = m_filterText
            findText()
            Exit Sub
        End If

        For Each element In hdoc.all
            If element.tagName = "A" Then
                If element.Name = myBookmark Then
                    element.scrollIntoView()
                    lstPages.SelectedIndex = lstPages.FindStringExact(myDescription)
                    Exit For
                End If
            End If
        Next element

    End Sub

[...]

    Private Sub findText()
        Static textRange As Object

        If m_filterText = "" Then Exit Sub

        If searchedOnce Then
            Call textRange.Move("word")
            If textRange.findText(m_filterText) Then
                textRange.Select()
            Else
                MsgBox("Not found anymore!")
            End If
        Else
            textRange = Nothing
            hdoc = Nothing
            hdoc = wbAct.Document
            textRange = hdoc.body.createTextRange
            If textRange.findText(m_filterText) Then
                textRange.Select()
            Else
                MsgBox("Search string not found.")
            End If
        End If
        searchedOnce = True
    End Sub

[...]

    Private Sub lstPages_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lstPages.Click
        myBookmark = lstPages.SelectedValue
        Dim element As Object
        For Each element In hdoc.all
            If element.tagName = "A" Then
                If element.Name = myBookmark Then
                    element.scrollIntoView()
                    Exit For
                End If
            End If
        Next element
    End Sub

    Private Sub btnOpen_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnOpen.Click
        If TypeOf (lstPages.SelectedValue) Is DBNull Then
            myBookmark = ""
        Else
            myBookmark = lstPages.SelectedValue
        End If
        Dim myItem As Integer = lstPages.SelectedIndex
        Dim a As DataRowView = lstPages.Items(myItem)
        myDescription = a.Item(1)
        myHeading = myActDir & " - " & myDescription
        Me.Text = myHeading
        Dim element As Object
        For Each element In hdoc.all
            If element.tagname = "DIV" Then
                If myBookmark = "" Then
                    element.scrollIntoView()
                    Exit For
                End If
            End If
            If element.tagName = "A" Then
                If element.Name = myBookmark Then
                    element.scrollIntoView()
                    Exit For
                End If
            End If
        Next element
    End Sub

Roger
0
 
Geo123Author Commented:
thanks very much for code sample that was good of you........ me thinks your a bit ahead of me with webstuf..lol!!

Will give it another stab as I do need to get this little project moving!!!

cheers

George
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

  • 4
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now