1,105,331 Community Members

Open Button Help

Member Avatar
IsaacMessi10
Junior Poster in Training
83 posts since Aug 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 6 [?]
 
0
 
Private Sub Open_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Open.Click
        If (BookmarksList.SelectedIndex >= 0) Then
            WebBrowser.WebBrowser1.Navigate(BookmarksList.SelectedItems)
        End If
End Sub

This is the code I made for opening a Bookmark from List yet an error keeps on showing. Any help?

WebBrowser is the main form's name.
BookmarksList is the List Box that contains the Bookmarks.

PS: I've just started to learn VB.NET

Member Avatar
tinstaafl
Postaholic
2,012 posts since Jun 2010
Reputation Points: 559 [?]
Q&As Helped to Solve: 402 [?]
Skill Endorsements: 35 [?]
 
1
 

When the error shows up, make note of the line it's on. That information is usually pretty important. Off the top of my head, I'd say try SelectedItem.Text instead of SelectedItems.

Member Avatar
IsaacMessi10
Junior Poster in Training
83 posts since Aug 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 6 [?]
 
0
 

I've changed it as you told me to and diplayed this error:

Public member 'Text' on type 'String' not found.

Member Avatar
G_Waddell
Practically a Posting Shark
821 posts since Nov 2009
Reputation Points: 131 [?]
Q&As Helped to Solve: 137 [?]
Skill Endorsements: 13 [?]
 
1
 

Hi,

WebBrowser.WebBrowser1.Navigate(BookmarksList.SelectedItems)

SelectedItems implies a collection to me - did intellisense highlight it?

I'd say your looking for either

WebBrowser.WebBrowser1.Navigate(BookmarksList.SelectedItem)

Or

WebBrowser.WebBrowser1.Navigate(BookmarksList.SelectedItems(0))

However, given the error message when you tried SelectedItem.Text is telling you text is not a valid member on type string I'd say the first option is the one you want i.e. SelectedItem

Member Avatar
IsaacMessi10
Junior Poster in Training
83 posts since Aug 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 6 [?]
 
0
 

WebBrowser.WebBrowser1.Navigate(BookmarksList.SelectedItems(0))

Dude it's perfect thanks.

Question Answered as of 11 Months Ago by G_Waddell and tinstaafl
You
This question has already been solved: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article