Visualizzazione dei risultati da 1 a 3 su 3

Discussione: [VB.NET] Web Browser

  1. #1

    [Vb.Net] web browser

    Ciao a tutti,
    vi preannuncio che non sono espertissimo di vb.net anzi lo sto ancora finendo di studiare però mi è venuto lo scribizzo di creare la seguente applicazione:

    Un mini browser utilizzando il modulo web già presente in Visual Studio e una mini text box in cui mettere l'indirizzo.

    Ora mettendo già come proprietà del browser l'indirizzo web appena apro il programma va ma ogni mia prova di fargli cambiare l'indirizzo è risultata vana.

    Sull'help di Visual Studio ho trovato la seguente sintassi per visualizzare per lo meno nella text box l'indirizzo corrente:

    codice:
    Dim webs As WebBrowserDocumentCompletedEventArgs
    
            txtIndirizzo.Text = webs.Url
    Però mi da errore dicendomi che non può convertire il tutto in formato String.

    Il codice completo della mia applicazione è il seguente:

    codice:
    Public Class Form1
    
        Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtIndirizzo.TextChanged
    
        End Sub
    
        Private Sub web_DocumentCompleted(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles web.DocumentCompleted
    
            Dim webs As WebBrowserDocumentCompletedEventArgs
    
            txtIndirizzo.Text = webs.Url
    
        End Sub
    End Class
    Sicuramente sarà qualche erroe stupido ma non riesco proprio ad individuarlo.

    Vi ringrazio in anticipo per l'aiuto,
    Neptune.

  2. #2
    Public Class Form1
    Inherits System.Windows.Forms.Form

    #Region " Windows Form Designer generated code "

    Public Sub New()
    MyBase.New()

    'This call is required by the Windows Form Designer.
    InitializeComponent()

    'Add any initialization after the InitializeComponent() call

    End Sub

    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
    If disposing Then
    If Not (components Is Nothing) Then
    components.Dispose()
    End If
    End If
    MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.
    'Do not modify it using the code editor.
    Friend WithEvents AxWebBrowser1 As AxSHDocVw.AxWebBrowser
    Friend WithEvents ToolBar1 As System.Windows.Forms.ToolBar
    Friend WithEvents ToolBarButton1 As System.Windows.Forms.ToolBarButton
    Friend WithEvents ToolBarButton2 As System.Windows.Forms.ToolBarButton
    Friend WithEvents ToolBarButton3 As System.Windows.Forms.ToolBarButton
    Friend WithEvents ToolBarButton4 As System.Windows.Forms.ToolBarButton
    Friend WithEvents ToolBarButton5 As System.Windows.Forms.ToolBarButton
    Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
    Friend WithEvents Button1 As System.Windows.Forms.Button
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
    Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(Form1))
    Me.AxWebBrowser1 = New AxSHDocVw.AxWebBrowser()
    Me.ToolBar1 = New System.Windows.Forms.ToolBar()
    Me.ToolBarButton1 = New System.Windows.Forms.ToolBarButton()
    Me.ToolBarButton2 = New System.Windows.Forms.ToolBarButton()
    Me.ToolBarButton3 = New System.Windows.Forms.ToolBarButton()
    Me.ToolBarButton4 = New System.Windows.Forms.ToolBarButton()
    Me.ToolBarButton5 = New System.Windows.Forms.ToolBarButton()
    Me.TextBox1 = New System.Windows.Forms.TextBox()
    Me.Button1 = New System.Windows.Forms.Button()
    CType(Me.AxWebBrowser1, System.ComponentModel.ISupportInitialize).BeginIni t()
    Me.SuspendLayout()
    '
    'AxWebBrowser1
    '
    Me.AxWebBrowser1.Enabled = True
    Me.AxWebBrowser1.Location = New System.Drawing.Point(8, 96)
    Me.AxWebBrowser1.OcxState = CType(resources.GetObject("AxWebBrowser1.OcxState" ), System.Windows.Forms.AxHost.State)
    Me.AxWebBrowser1.Size = New System.Drawing.Size(656, 288)
    Me.AxWebBrowser1.TabIndex = 0
    '
    'ToolBar1
    '
    Me.ToolBar1.Buttons.AddRange(New System.Windows.Forms.ToolBarButton() {Me.ToolBarButton1, Me.ToolBarButton2, Me.ToolBarButton3, Me.ToolBarButton4, Me.ToolBarButton5})
    Me.ToolBar1.DropDownArrows = True
    Me.ToolBar1.Name = "ToolBar1"
    Me.ToolBar1.ShowToolTips = True
    Me.ToolBar1.Size = New System.Drawing.Size(672, 39)
    Me.ToolBar1.TabIndex = 1
    '
    'ToolBarButton1
    '
    Me.ToolBarButton1.Text = "Pagina Iniziale"
    '
    'ToolBarButton2
    '
    Me.ToolBarButton2.Text = "Aggiorna"
    '
    'ToolBarButton3
    '
    Me.ToolBarButton3.Text = "Precedente"
    '
    'ToolBarButton4
    '
    Me.ToolBarButton4.Text = "Successiva"
    '
    'ToolBarButton5
    '
    Me.ToolBarButton5.Text = "Stop"
    '
    'TextBox1
    '
    Me.TextBox1.Location = New System.Drawing.Point(16, 56)
    Me.TextBox1.Name = "TextBox1"
    Me.TextBox1.Size = New System.Drawing.Size(456, 20)
    Me.TextBox1.TabIndex = 2
    Me.TextBox1.Text = ""
    '
    'Button1
    '
    Me.Button1.Location = New System.Drawing.Point(496, 56)
    Me.Button1.Name = "Button1"
    Me.Button1.Size = New System.Drawing.Size(96, 24)
    Me.Button1.TabIndex = 3
    Me.Button1.Text = "Vai a URL"
    '
    'Form1
    '
    Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
    Me.ClientSize = New System.Drawing.Size(672, 397)
    Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.Button1, Me.TextBox1, Me.ToolBar1, Me.AxWebBrowser1})
    Me.Name = "Form1"
    Me.Text = "Form1"
    CType(Me.AxWebBrowser1, System.ComponentModel.ISupportInitialize).EndInit( )
    Me.ResumeLayout(False)

    End Sub

    #End Region

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    Dim MyUrl As String
    MyUrl = TextBox1.Text
    Cursor.Current = Cursors.WaitCursor
    AxWebBrowser1.Navigate(MyUrl, "", "", "", "")
    Cursor.Current = Cursors.Default
    End Sub

    Private Sub ToolBar1_ButtonClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ToolBarButtonClickEventArgs) Handles ToolBar1.ButtonClick
    If (e.Button Is ToolBarButton1) Then
    AxWebBrowser1.GoHome()
    End If
    If (e.Button Is ToolBarButton2) Then
    AxWebBrowser1.Refresh()
    End If
    If (e.Button Is ToolBarButton3) Then
    AxWebBrowser1.GoBack()
    End If
    If (e.Button Is ToolBarButton4) Then
    AxWebBrowser1.GoForward()
    End If
    If (e.Button Is ToolBarButton5) Then
    AxWebBrowser1.Stop()
    End If

    End Sub
    End Class

  3. #3
    Tutto ciò cosa sarebbe?

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.