| | |
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:
Solved Threads: 0
right changed a bit so i can now get the urls to populate in a combobox.
Is that code okay or would there be a better way to find viewed websites?
VB.NET Syntax (Toggle Plain Text)
Imports System Imports Microsoft.Win32 Imports System.Windows.Forms Public Class Form1 Public Function PopulateUrlList() As List(Of String) Dim regKey As String = "Software\Microsoft\Internet Explorer\TypedURLs" Dim subKey As RegistryKey = Registry.CurrentUser.OpenSubKey(regKey) Dim url As String Dim urlList As New List(Of String)() Dim counter As Integer = 1 While True Dim sValName As String = "url" + counter.ToString() url = DirectCast(subKey.GetValue(sValName), String) If DirectCast(url, Object) Is Nothing Then Exit While End If urlList.Add(url) ComboBox1.Items.Add(url) counter += 1 End While Return urlList End Function Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Call PopulateUrlList() End Sub End Class
Is that code okay or would there be a better way to find viewed websites?
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.
vb.net Syntax (Toggle Plain Text)
Imports System Imports Microsoft.Win32 Imports System.Windows.Forms Public Class Form1 Public Function PopulateUrlList() As List(Of String) Dim regKey As String = "Software\Microsoft\Internet Explorer\TypedURLs" Dim subKey As RegistryKey = Registry.CurrentUser.OpenSubKey(regKey) Dim url As String Dim urlList As New List(Of String)() Dim counter As Integer = 1 While True Dim sValName As String = "url" + counter.ToString() url = DirectCast(subKey.GetValue(sValName), String) If DirectCast(url, Object) Is Nothing Then Exit While End If urlList.Add(url) counter += 1 End While Return urlList End Function Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click dim urls as new List(of string)() dim I as integer urls = PopulateUrlList() for I = 0 to urls.count -1 ' maybe i = 1 to urls.count ComboBox1.Items.Add(url) next I End Sub End Class
•
•
Join Date: Jul 2007
Posts: 276
Reputation:
Solved Threads: 37
•
•
•
•
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
VB.NET Syntax (Toggle Plain Text)
ComboBox1.Items.Add(urls)
No No, It was faulty code
:
: vb.net Syntax (Toggle Plain Text)
dim urls as new List(of string)() dim I as integer urls = PopulateUrlList() for I = 0 to urls.count -1 ' maybe i = 1 to urls.count ComboBox1.Items.Add(urls(i)) ' // oops! next I
Last edited by Comatose; Jan 8th, 2009 at 1:52 pm.
•
•
Join Date: Jun 2009
Posts: 4
Reputation:
Solved Threads: 1
I know and If you were making your own IE then that would work because the Webbrowser control is basicly IE.
![]() |
Similar Threads
- .NET Software Applications Developer (Software Development Job Offers)
Other Threads in the VB.NET Forum
- Previous Thread: Displaying time in a text box
- Next Thread: VB.NET
| Thread Tools | Search this Thread |
"crystal .net .net2005 30minutes 2008 access add application array assignment basic binary box button buttons center click code combo connectionstring convert cpu data database databasesearch datagrid datagridview design dissertation dissertations dissertationthesis dosconsolevb.net editvb.net employees excel exists firewall folder function image images isnumericfuntioncall listview login map math memory mobile module msaccess mssqlbackend mysql navigate net opacity page pan peertopeervideostreaming picturebox plugin port print printing printpreview record regex reports" reuse right-to-left save savedialog search serial socket sorting sql sqldatbase storedprocedure string structures studio temp textbox timer txttoxmlconverter upload useraccounts usercontrol vb vb.net vb.netcode vb.nettoolboxvisualbasic2008sidebar vbnet vista visual visualbasic visualbasic.net web wpf xml






