To register for an Internet.com membership to receive newsletters and white papers, use the Register button ABOVE.
To participate in the message forums BELOW, click here
VBForums  

VB Wire News
Part 10 of the Visual Basic .NET 2010 Express Tutorial Complete!
How to Use the Visual Studio Code Analysis Tool FxCop
Article :: Interview with Andrei Alexandrescu (Part 3 of 3)
Introducing Visual Studio LightSwitch
Visual Studio LightSwitch Beta 1 is Available



Go Back   VBForums > Visual Basic > Visual Basic 6 and Earlier

Reply Post New Thread
 
Thread Tools Display Modes
Old May 24th, 2006, 12:59 PM   #1
arpan_de
Frenzied Member
 
arpan_de's Avatar
 
Join Date: Oct 05
Location: Mumbai, India
Posts: 1,394
arpan_de is on a distinguished road (10+)
Question Confusion Galore!

In a Web Browser project, whichever web page a user has navigated to, I am adding the titles of the web pages along with their respective URLs in a text file. I am then populating 2 Collections - one with the title of the web page & the other one with the URL of the web page. This is how I am doing it:
VB Code:
  1. Private Sub wWeb_TitleChange(ByVal Text As String)
  2.     Dim iFile As Integer
  3.     Dim FileName As String
  4.     Dim colTitle As Collection
  5.     Dim colURL As Collection
  6.     Set colTitle = New Collection
  7.     Set colURL = New Collection
  8.     iFile = FreeFile
  9.     FileName = App.Path & "\SessionHistory.txt"
  10.     Open FileName For Input As #iFile
  11.         Do While Not EOF(iFile)
  12.             Input #iFile, strTitle, strURL
  13.             colTitle.Add strTitle, strTitle
  14.             colURL.Add strURL, strURL
  15.         Loop
  16.     Close #iFile
  17. End Sub
There is another function (not shown) which loads a menu with these web pages. The web page the user currently is in is checked in the menu. A user can navigate in 2 ways - either by clicking a link or by pressing the Back/Forward buttons. If the Back or Forward button is pressed then a Public Boolean blnNavButtons is set to True & in the BeforeNavigate2 event function:
VB Code:
  1. Private Sub wWeb_BeforeNavigate2(ByVal pDisp As Object, URL As Variant, Flags As Variant, TargetFrameName As Variant, PostData As Variant, Headers As Variant, Cancel As Boolean)
  2.     If (blnNavButtons = True) Then
  3.         blnLinkClick = False
  4.     Else
  5.         blnLinkClick = True
  6.     End If
  7. End Sub
Assume that a user goes to Page1, clicks a link & goes to Page2. In Page2, he again clicks a link which takes him to Page3 & finally in Page3, he clicks a link which takes him to Page4. Note that while he is navigating, the menu is simultaneously getting loaded with Page1, Page2, Page3 & Page4 which is now checked.

Right now, the user is in Page4. Now assume that he clicks the Back button & goes to Page3. Again he clicks the Back button & goes to Page2. Again he clicks the Back button which takes him to Page1. Now if the user clicks a link in Page1 which takes the user to Page5, I want Page2, Page3 & Page4 to get deleted from the Collections as well as from the menu. This is how I have done it (continuing wWeb_TitleChange where it has been left):
VB Code:
  1. Private Sub wWeb_TitleChange(ByVal Text As String)
  2.     ..........
  3.     ..........
  4.     ..........
  5.     Close #iFile
  6.     For i = 1 To colURL.Count
  7.         If (colURL.Item(i) = wWeb.LocationURL) Then
  8.             If (colURL.Count > i) Then
  9.                 If (blnLinkClick = True) Then
  10.                     For j = i + 1 To colURL.Count
  11.                         colURL.Remove j
  12.                         colTitle.Remove j
  13.                         Unload mnuSessionHistory(j - 1)
  14.                     Next j
  15.                     FileName = App.Path & "\SessionHistory.txt"
  16.                     Open FileName For Output As #iFile
  17.                         For j = 0 To mnuSessionHistory.UBound
  18.                             Write #iFile, mnuSessionHistory(j).Caption, mnuSessionHistory(j).Tag
  19.                         Next
  20.                     Close #iFile
  21.                 End If
  22.             End If
  23.         End If
  24.     Next i
  25. End Sub
The above code works fine but a problem creeps under the following circumstance:

User goes to Page1, clicks a link & goes to Page2, clicks a link & goes to Page3, clicks a link & goes to Page4. The menu now looks like this:

Code:
Page1
Page2
Page3
Page4
Page4 is checked. Now in Page 4, there is a link which takes the user back to Page1. So when this link is clicked, all the menu items get deleted & only Page1 remains in the menu where as I want the menu to look like this:

Code:
Page1
Page2
Page3
Page4
Page1
With Page1 checked.

What modifications are needed in the above code to do this?
__________________


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?
arpan_de is offline   Reply With Quote
Reply

Go Back   VBForums > Visual Basic > Visual Basic 6 and Earlier


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 05:31 AM.





Acceptable Use Policy

Internet.com
The Network for Technology Professionals

Search:

About Internet.com

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers

Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.