Thursday, May 16, 2013

How to create your own web browser in vb.net


Steps:
1.Using VB Toolbox -> Web Browser to design tools as photo
2. And design a other function tools as you see in photo
3. Using the code below you see :

Public Class Form1

    Private Sub cmdGo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdGo.Click
        Explorer.Navigate(txtAddress.Text)
    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        txtAddress.Text = "http://www.google.com"
        Explorer.Navigate(txtAddress.Text)
    End Sub

    Private Sub cmdBack_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdBack.Click
        Explorer.GoBack()
        txtAddress.Text = Explorer.Url.Host
    End Sub

    Private Sub cmdForward_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdForward.Click
        Explorer.GoForward()
        txtAddress.Text = Explorer.Url.Host
    End Sub

    Private Sub cmdStop_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdStop.Click
        Explorer.Stop()
    End Sub

    Private Sub cmdHome_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdHome.Click
        Explorer.Navigate("http://www.youtube.com")
        txtAddress.Text = Explorer.Url.Host
        'Explorer.GoHome()
    End Sub

    Private Sub cmdSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdSearch.Click
        Explorer.GoSearch()
        txtAddress.Text = Explorer.Url.Host
    End Sub

    Private Sub cmdRefresh_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdRefresh.Click
        Explorer.Refresh()
        txtAddress.Text = Explorer.Url.Host
    End Sub

    Private Sub Explorer_ProgressChanged(ByVal sender As Object, ByVal e As System.Windows.Forms.WebBrowserProgressChangedEventArgs) Handles Explorer.ProgressChanged
        ProgressBar.Maximum = e.MaximumProgress
        ProgressBar.Value = e.CurrentProgress
        Try
            Label.Text = "Progressing..."
            If ProgressBar.Maximum = ProgressBar.Value Then
                Label.Text = "Done"
            End If
        Catch ex As Exception
            Label.Text = "Error loading page!"
        End Try

    End Sub
End Class


By RUPP Student



1 comment: