Reputation: 115
I have an listbox which has some random URLs + basic info, eg:
[search website] - http://www.google.com/
[games website] - http://www.miniclip.com/
Each line is an item.
When I try to use this code, it crashes:
Private Sub doubleclickitem(sender As Object, e As EventArgs) Handles ListBox1.DoubleClick
Dim url As String = ListBox1.SelectedItem
Process.Start(url)
End Sub
The error is the first characters are unknown for Process.Start
.
How can I start the url? Someone told me I have to read the lines after the first " - ". Is this right? If so, how can I do so?
Upvotes: 2
Views: 9853
Reputation: 825
Try this:
YourTextBox.Text = YourString.Substring(0, YourString.Text.LastIndexOf(" - "))
Upvotes: 0
Reputation: 1231
you should be assigning a value to each text item in the list, then retrieving the value, and feeding that to process.start, for example if you want process.start to open google, then it would be like so....(provided you assign a value of http://www.google.com to whatever the selected item is)
Process.Start(ListBox1.SelectedValue)
this is for c#, but the same ideals will still apply http://forums.asp.net/t/1199141.aspx/1
Upvotes: 0
Reputation: 46919
This should do it:
url = url.Substring(url.LastIndexOf(" - ") + 3)
Upvotes: 1