开发者

Convert URI to String

开发者 https://www.devze.com 2023-02-24 16:27 出处:网络
Visual Basic 2010. Dim selection As String = ListBox1.SelectedItem Dim url As String = Split(selection, \" - \")

Visual Basic 2010.

Dim selection As String = ListBox1.SelectedItem
Dim url As String = Split(selection, " - ")
Form1.WebBrowser1.Navigate(url(1))

I want to convert the URI (Value of type '1-dimensional array of string' cannot be converted to 'string') to a string. How would I do so?

(The selection variable is something like "Title - URL")

Thanks!

开发者_开发知识库
  • The error is on Split(selection, " - ")


May be your error is at Getting the Split Parts of the Selection to the Url, where you have used normal string instead of One-Dimensional Array Declaration.


Split function will return array of string. But you are trying to assign its value to "string". To declare a array use the below code

Dim url() As String = Split(selection, " - ")

To know about vb array refer the link. http://www.startvbdotnet.com/language/arrays.aspx

Also one wise way to store url in ListItem is, Set the URL in Value field and Display text in Text field. So that, you can retrieve url from value easily without any string processing.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号