|
-
Jan 14th, 2008, 10:02 AM
#1
Thread Starter
Frenzied Member
-
Jan 14th, 2008, 10:37 AM
#2
Re: Store Visiting Pages In Array
Try something like this - it is presumed that your webbrosers are control array (I used textbox lfor simplicity):
Code:
Option Explicit
Private Type URL
URL() As String
End Type
Dim arUrls() As URL
Private Sub Form_Load()
Dim i%
ReDim Preserve arUrls(Text1.UBound)
For i = 0 To UBound(arUrls)
ReDim arUrls(i).URL(0)
Next i
End Sub
Private Sub Text1_KeyPress(Index As Integer, KeyAscii As Integer)
'add url to array
'NOTE: you may need to scan current array for dups before inserting new item;
' don't scan it if you want to keep entire history
If KeyAscii = 13 Then
arUrls(Index).URL(UBound(arUrls(Index).URL)) = Text1(Index).Text
ReDim Preserve arUrls(Index).URL(UBound(arUrls(Index).URL) + 1)
End If
End Sub
'run this to test what's in the array
Private Sub Command1_Click()
Dim i%
For i = 0 To UBound(arUrls(0).URL) 'I'm only checking main array's first element
Debug.Print arUrls(0).URL(i)
Next i
End Sub
-
Jan 14th, 2008, 12:49 PM
#3
Thread Starter
Frenzied Member
-
Jan 14th, 2008, 01:24 PM
#4
Re: Store Visiting Pages In Array
You can still use that array but you will need to add some unique identifier to URL type and also make it public.
-
Jan 14th, 2008, 01:37 PM
#5
Re: Store Visiting Pages In Array
Code:
Option Explicit
Private Type URLRecord
Browser As String
url As String
End Type
Private Sub Form_Load()
Dim ur() As URLRecord
ReDim ur(0)
ur(UBound(ur)).Browser = "blah"
ur(UBound(ur)).url = "www.vfforums.com"
' for each new entry
ReDim Preserve ur(UBound(ur) + 1)
End Sub
-
Jan 14th, 2008, 02:35 PM
#6
Thread Starter
Frenzied Member
-
Jan 14th, 2008, 03:08 PM
#7
Re: Store Visiting Pages In Array
Code:
Dim ur() As URLRecord
Dim lngIndex As Long
Dim strBrowser As String
Dim strURL As String
Dim x As Integer
ReDim ur(0)
Do
strBrowser = InputBox("Browser name")
strURL = InputBox("URL")
For lngIndex = 0 To UBound(ur)
If strBrowser = ur(lngIndex).Browser And strURL = ur(lngIndex).url Then
Exit For
Else
ur(UBound(ur)).Browser = strBrowser
ur(UBound(ur)).url = strURL
ReDim Preserve ur(UBound(ur) + 1)
End If
Next
' for testing
x = x + 1
If x = 3 Then Exit Do
Loop
ReDim Preserve ur(UBound(ur) - 1)
For lngIndex = 0 To UBound(ur)
Debug.Print ur(lngIndex).Browser & " - " & ur(lngIndex).url
Next
-
Jan 14th, 2008, 09:11 PM
#8
Thread Starter
Frenzied Member
Re: Store Visiting Pages In Array
Thanks, Martin, for the code but I couldn't make it work. If I visit a URL, it gets added to the array...that's fine but if I visit that URL again, it again gets added to the array. Here are the changes I made:
Code:
Private Type URLRecord
PgURL As String
PgTitle As String
End Type
Private Sub wWeb_DownloadComplete()
Dim ur() As URLRecord
Dim lngIndex As Long
Dim strTitle As String
Dim strURL As String
Dim x As Integer
ReDim ur(0)
Do
strTitle = wWeb.LocationName
strURL = wWeb.LocationURL
For lngIndex = 0 To UBound(ur)
If strTitle = ur(lngIndex).PgTitle And strURL = ur(lngIndex).PgURL Then
Exit For
Else
ur(UBound(ur)).PgTitle = strTitle
ur(UBound(ur)).PgURL = strURL
ReDim Preserve ur(UBound(ur) + 1)
End If
Next
' for testing
x = x + 1
If x = 3 Then Exit Do
Loop
ReDim Preserve ur(UBound(ur) - 1)
For lngIndex = 0 To UBound(ur)
Debug.Print ur(lngIndex).PgTitle & " - " & ur(lngIndex).PgURL
Next
End Sub
Any idea where I could be going through?
Note that I have put your code in the DownloadComplete event of the WebBrowser control. Is that the correct place to put your code? I am not sure....
Also could you please explain me the logic behind your code? I couldn't exactly follow it....
Giving you lot of trouble, isn't it?
ARPAN
IF YOU HAVE AN APPLE & I HAVE AN APPLE AND WE EXCHANGE THE APPLES, THEN YOU & I WILL STILL HAVE ONE APPLE BUT IF YOU HAVE AN IDEA & I HAVE AN IDEA AND WE EXCHANGE OUR IDEAS, THEN EACH OF US WILL HAVE TWO IDEAS!
NOTHING IS IMPOSSIBLE IN THIS WORLD.....EVEN THE WORD IMPOSSIBLE SAYS I'M POSSIBLE!
PRACTICE MAKES A MAN PERFECT BUT NOBODY IS PERFECT; SO WHY PRACTICE?
-
Jan 14th, 2008, 09:25 PM
#9
Re: Store Visiting Pages In Array
Code:
Private Sub wWeb_DownloadComplete()
Dim ur() As URLRecord 'move this and the line below that also is commented with "move"
'out of wWeb_DownloadComplete and put them someplace where they will
'only be done once
Dim lngIndex As Long
Dim strTitle As String
Dim strURL As String
Dim x As Integer
ReDim ur(0) 'move (see above)
Do ' You don't need this since I assume that you only want to add one entry
' every time wWeb_DownloadComplete
strTitle = wWeb.LocationName
strURL = wWeb.LocationURL
For lngIndex = 0 To UBound(ur)
If strTitle = ur(lngIndex).PgTitle And strURL = ur(lngIndex).PgURL Then
Exit For
Else
ur(UBound(ur)).PgTitle = strTitle
ur(UBound(ur)).PgURL = strURL
ReDim Preserve ur(UBound(ur) + 1)
End If
Next
' none of the next three lines are needed
x = x + 1
If x = 3 Then Exit Do
Loop
ReDim Preserve ur(UBound(ur) - 1)
'you don't need this either
For lngIndex = 0 To UBound(ur)
Debug.Print ur(lngIndex).PgTitle & " - " & ur(lngIndex).PgURL
Next
End Sub
-
Jan 15th, 2008, 01:08 AM
#10
Thread Starter
Frenzied Member
Re: Store Visiting Pages In Array
'move this and the line below that also is commented with "move" out of wWeb_DownloadComplete and put them someplace where they will only be done once
What do you mean by "some place"? Should those 2 lines be put in an event function of the WebBrowser control or can it put in any Form/other controls' event function?
ARPAN
IF YOU HAVE AN APPLE & I HAVE AN APPLE AND WE EXCHANGE THE APPLES, THEN YOU & I WILL STILL HAVE ONE APPLE BUT IF YOU HAVE AN IDEA & I HAVE AN IDEA AND WE EXCHANGE OUR IDEAS, THEN EACH OF US WILL HAVE TWO IDEAS!
NOTHING IS IMPOSSIBLE IN THIS WORLD.....EVEN THE WORD IMPOSSIBLE SAYS I'M POSSIBLE!
PRACTICE MAKES A MAN PERFECT BUT NOBODY IS PERFECT; SO WHY PRACTICE?
-
Jan 15th, 2008, 08:49 AM
#11
Re: Store Visiting Pages In Array
 Originally Posted by arpan_de
... if I visit that URL again, it again gets added to the array...
In my opinion that's how it should work - look at IE history and you will see list of all the pages you visited and not only unique ones.
You may limit however number of entries in your array if you wish.
-
Jan 15th, 2008, 11:31 AM
#12
Re: Store Visiting Pages In Array
 Originally Posted by arpan_de
What do you mean by "some place"? Should those 2 lines be put in an event function of the WebBrowser control or can it put in any Form/other controls' event function?
I assume that you have a place in your app where you do various initialization type coding. Put the two lines there.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|