2016-07-02 64 views
1

我試圖通過關注YouTube視頻來測試我的網絡瀏覽器。它雖然不起作用。它有什麼問題?Microsoft Visual Basic 2008速成版期末聲明

這裏是我的代碼

Public Class Form1 

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 
    WebBrowser1.Navigate("www.google.com") 
End Sub 

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click 
    WebBrowser1.GoBack() 
End Sub 

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click 
    WebBrowser1.GoForward() 
End Sub 

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click 
    WebBrowser1.Navigate(TextBox1.Text) 
End Sub 

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click 
    WebBrowser1.Navigate("http://www.google.com/search?g=") & (TextBox2.Text) 
End Sub 

Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click 
    WebBrowser1.Stop() 
End Sub 

Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click 
    WebBrowser1.Refresh() 
End Sub 

End Class 

回答

1

你不說哪裏出現了錯誤,這使得它很難幫助你。但它看起來像你的問題是在這條線:

WebBrowser1.Navigate("http://www.google.com/search?g=") & (TextBox2.Text) 

這應該是

WebBrowser1.Navigate("http://www.google.com/search?g=" & TextBox2.Text) 

正因爲如此,你必須對自己的線的表達;連接是沒有意義的。


在未來,請務必包括Minimal, Complete, and Verifiable example.問題尋求幫助調試(「爲什麼不是這個代碼工作?」)必須包括所期望的行爲,一特定問題或錯誤必要的最短代碼重現它在問題本身。沒有的問題明確的問題陳述對其他讀者沒有用處。

0

我只是想通了。我收集了YouTuber,他們回覆了。這是正確的代碼。

公共類Form1中

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 
    WebBrowser1.Navigate("www.google.com") 
End Sub 

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click 
    WebBrowser1.GoBack() 
End Sub 

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click 
    WebBrowser1.GoForward() 
End Sub 

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click 
    WebBrowser1.Navigate(TextBox1.Text) 
End Sub 

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click 
    WebBrowser1.Navigate("http://www.google.com/search?g=" & TextBox2.Text) 
End Sub 

Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click 
    WebBrowser1.Stop() 
End Sub 

Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click 
    WebBrowser1.Refresh() 
End Sub 

末級