如何使用标签或文本框构建和打开撰写的URL

时间:2018-05-07 07:03:39

标签: vb.net google-chrome internet-explorer url

我使用此代码:

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    Dim url1 As String = "https://www.google.com.mx/search?q=" & adress.Text
    Process.Start(url1)
End Sub

我也尝试使用+代替& chrome打开但只是“https://www.google.com.mx/search?q=”作为URL,总是缺少控件文本部分!

我必须如何格式化此代码?

1 个答案:

答案 0 :(得分:0)

这解决了问题

Private Sub Search_Click(sender As Object, e As EventArgs) Handles Search.Click

    Dim MyUrl As String = (adress.Text)
    Dim EncodedURL As String = System.Web.HttpUtility.UrlEncode(MyUrl)
    Dim url2 As String
    url2 = String.Format("https://www.google.com.mx/search?q=" & EncodedURL & ", " & adress.Text & ", " & country.Text)
    Process.Start(url2)
End Sub