How would I take a website name and say log it to a text file? Kinda like what the temp internet files does under microsoft internet explore, and kinda like what the history files do under microsoft internet explore.
Printable View
How would I take a website name and say log it to a text file? Kinda like what the temp internet files does under microsoft internet explore, and kinda like what the history files do under microsoft internet explore.
If it's the file writing you're having trouble with then the easiest way is to use the FileSystemObject. Go to the Project menu and hit References. Then you will be presented with a big list of checkboxes, somewhere on the list is one called "Microsoft Scripting Runtime" select this and press OK.
add a text box and a command putton to your form and add this code
Code:Option Explicit
'Edit this to change the name of the file, you can have it as a variable and not a constant if you want.
Const MyFileName As String = "C:\MyFile.txt"
'This is a component that handles all the hard stuff about writing files
Dim FSO As New FileSystemObject
'This is the way it handles a text file
Dim MyFile As TextStream
Private Sub Command1_Click()
'just write a line to the end of the file
MyFile.WriteLine Text1.Text
End Sub
Private Sub Form_Load()
'We open the file here and leve it open all through the progrem.
'It closes itself at the end, but if you want to close it before use
'Set MyFile = Nothing
'If the File we want already exists
If FSO.FileExists(MyFileName) Then
'Open the file For appending as MyFile
Set MyFile = FSO.OpenTextFile(MyFileName, ForAppending)
Else
'Create a new textfile as MyFile
Set MyFile = FSO.CreateTextFile(MyFileName)
End If
End Sub
This will add whatever is written in text1 to the file specified, you can modify this to save names of websites.
do you want to get the curent URL and window title from your browser too? if so, see my reply at
http://forums.vb-world.net/showthrea...threadid=25452
If you want to use your own Webbrowser using ShDocVw.dll:
Code:Private Sub WebBrowser1_NavigateComplete2(ByVal pDisp As Object, URL As Variant)
Open App.Path & "\visited.log" For Append As #1
Print #1, URL 'Webbrowser1.LocationURL can do the same, which ever one you feel more comfortable using.
Close #1
End Sub
Ok, sorry about that, if i am useing microsoft internet explore, how could i write every page i go to, into a text file? so if i whent to yahoo.com it would make a file with yahoo.com in it. or i whent to compaq.com right after i whent to yahoo.com the text file would look like this
yahoo.com
compaq.com
so basicly i just want to know every site that has been visited.
poll every second using my code mentioned above. Then print to a text file using
I know it works, i do it in a monitoring app. I write to a database, though.Code:Dim FF as Integer
FF = FreeFile
Open "MyFile.txt" for Append as #FF
Print #FF,BrowserName; "-"; WindowTitle