vb.net 08 Show all visited websites

Please support our VB.NET advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Mar 2008
Posts: 44
Reputation: smelf1 is an unknown quantity at this point 
Solved Threads: 0
smelf1 smelf1 is offline Offline
Light Poster

Re: vb.net 08 Show all visited websites

 
0
  #11
Jan 8th, 2009
right changed a bit so i can now get the urls to populate in a combobox.

  1. Imports System
  2. Imports Microsoft.Win32
  3. Imports System.Windows.Forms
  4.  
  5. Public Class Form1
  6.  
  7. Public Function PopulateUrlList() As List(Of String)
  8. Dim regKey As String = "Software\Microsoft\Internet Explorer\TypedURLs"
  9. Dim subKey As RegistryKey = Registry.CurrentUser.OpenSubKey(regKey)
  10. Dim url As String
  11. Dim urlList As New List(Of String)()
  12. Dim counter As Integer = 1
  13. While True
  14. Dim sValName As String = "url" + counter.ToString()
  15. url = DirectCast(subKey.GetValue(sValName), String)
  16. If DirectCast(url, Object) Is Nothing Then
  17. Exit While
  18. End If
  19. urlList.Add(url)
  20. ComboBox1.Items.Add(url)
  21. counter += 1
  22. End While
  23. Return urlList
  24. End Function
  25.  
  26. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  27. Call PopulateUrlList()
  28. End Sub
  29. End Class

Is that code okay or would there be a better way to find viewed websites?
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 2,413
Reputation: Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough 
Solved Threads: 211
Team Colleague
Comatose's Avatar
Comatose Comatose is offline Offline
Taboo Programmer

Re: vb.net 08 Show all visited websites

 
0
  #12
Jan 8th, 2009
That code is fantastic. The only thing that I would mention about it... is that you are using the function to work with your form. On a small scale project, this is fine (and I've seen it used on large scale projects too), but keep in mind that this defeats the entire purpose of a function. Why even use a function... why not put all that code in the Button1_Click Event? The function is meant to be used to GET the list of URL's.... actually displaying them to the user is a different process... a different concept. So getting the data, and showing the data should not be combined.
  1. Imports System
  2. Imports Microsoft.Win32
  3. Imports System.Windows.Forms
  4.  
  5. Public Class Form1
  6.  
  7. Public Function PopulateUrlList() As List(Of String)
  8. Dim regKey As String = "Software\Microsoft\Internet Explorer\TypedURLs"
  9. Dim subKey As RegistryKey = Registry.CurrentUser.OpenSubKey(regKey)
  10. Dim url As String
  11. Dim urlList As New List(Of String)()
  12. Dim counter As Integer = 1
  13. While True
  14. Dim sValName As String = "url" + counter.ToString()
  15. url = DirectCast(subKey.GetValue(sValName), String)
  16. If DirectCast(url, Object) Is Nothing Then
  17. Exit While
  18. End If
  19. urlList.Add(url)
  20. counter += 1
  21. End While
  22. Return urlList
  23. End Function
  24.  
  25. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  26. dim urls as new List(of string)()
  27. dim I as integer
  28. urls = PopulateUrlList()
  29.  
  30. for I = 0 to urls.count -1 ' maybe i = 1 to urls.count
  31. ComboBox1.Items.Add(url)
  32. next I
  33. End Sub
  34. End Class
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 44
Reputation: smelf1 is an unknown quantity at this point 
Solved Threads: 0
smelf1 smelf1 is offline Offline
Light Poster

Re: vb.net 08 Show all visited websites

 
0
  #13
Jan 8th, 2009
i am only using it in a small program, but if i try your code i get (collection) a load of times in the combo box. Also it says
ComboBox1.Items.Add(urls)
url is not defined so i assume it meant to be urls
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 276
Reputation: rapture has a spectacular aura about rapture has a spectacular aura about 
Solved Threads: 37
rapture rapture is offline Offline
Posting Whiz in Training

Re: vb.net 08 Show all visited websites

 
0
  #14
Jan 8th, 2009
Originally Posted by smelf1 View Post
i am only using it in a small program, but if i try your code i get (collection) a load of times in the combo box. Also it says
ComboBox1.Items.Add(urls)
url is not defined so i assume it meant to be urls
correct, he used url in the first part and urls in the second, it should probably be

  1. ComboBox1.Items.Add(urls)
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 44
Reputation: smelf1 is an unknown quantity at this point 
Solved Threads: 0
smelf1 smelf1 is offline Offline
Light Poster

Re: vb.net 08 Show all visited websites

 
0
  #15
Jan 8th, 2009
ah yeah i changed it to urls before hand and thats when i get (collection) numerous times in the combo box.
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 276
Reputation: rapture has a spectacular aura about rapture has a spectacular aura about 
Solved Threads: 37
rapture rapture is offline Offline
Posting Whiz in Training

Re: vb.net 08 Show all visited websites

 
0
  #16
Jan 8th, 2009
I'm not 10% of the programmer these other guys are, but what I do at this point is insert a breakpoint and step through the code to see where the disconnect is.
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 2,413
Reputation: Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough 
Solved Threads: 211
Team Colleague
Comatose's Avatar
Comatose Comatose is offline Offline
Taboo Programmer

Re: vb.net 08 Show all visited websites

 
0
  #17
Jan 8th, 2009
No No, It was faulty code :
  1. dim urls as new List(of string)()
  2. dim I as integer
  3. urls = PopulateUrlList()
  4.  
  5. for I = 0 to urls.count -1 ' maybe i = 1 to urls.count
  6. ComboBox1.Items.Add(urls(i)) ' // oops!
  7. next I
Last edited by Comatose; Jan 8th, 2009 at 1:52 pm.
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 44
Reputation: smelf1 is an unknown quantity at this point 
Solved Threads: 0
smelf1 smelf1 is offline Offline
Light Poster

Re: vb.net 08 Show all visited websites

 
0
  #18
Jan 9th, 2009
cool thats sorted it comatose.

Thanks alot.
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 4
Reputation: Micheal_2009 is an unknown quantity at this point 
Solved Threads: 1
Micheal_2009 Micheal_2009 is offline Offline
Newbie Poster

Re: vb.net 08 Show all visited websites

 
0
  #19
Jun 18th, 2009
Originally Posted by Comatose View Post
What's interesting here, is that both methods are pretty great..... but neither one of them gets the typed URL's of a browser other than IE. What about getting the history of Firefox.... Opera.... Chrome?
I know and If you were making your own IE then that would work because the Webbrowser control is basicly IE.
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 276
Reputation: rapture has a spectacular aura about rapture has a spectacular aura about 
Solved Threads: 37
rapture rapture is offline Offline
Posting Whiz in Training

Re: vb.net 08 Show all visited websites

 
0
  #20
Jun 19th, 2009
Please don't post to threads this old . . .

Thanks!
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the VB.NET Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC