Solved

Remember the latest 10 folders that I have opened

Posted on 1998-08-26
2
132 Views
Last Modified: 2010-04-30
I'd like to create a program that can remember the latest 10 folders that I have opened.
The program must work from any folder I open.

Example:
If I open "My Computer" there should be a button on the title bar where I can choose to go to one of the folders I have been in.

Norton Navigator can do this, but I don't feel like bying that.

How many points do you want for that?
0
Comment
Question by:jfl
2 Comments
 
LVL 14

Accepted Solution

by:
waty earned 20 total points
Comment Utility
You find a call on my web site implement MRU (Most Recently Used). You could use this class for your job.

http://www.geocities.com/ResearchTriangle/6311/


By the way, here is code  :

Option Explicit

' ***
' *** An object to maintain the last files opened
' *** opened by a program
' ***
' *** class_MRU gives you a quick and reliable way to provide a Most-Recently Used (MRU) file
' *** list in your application.

Private colMRUFiles  As New Collection
Private Num          As Integer

Public Sub Add(file As String)

   If colMRUFiles.count = 0 Then
      colMRUFiles.Add file, UCase(file)
   Else
      On Error Resume Next
      colMRUFiles.Remove UCase(file)
      colMRUFiles.Add file, UCase(file), 1
      If colMRUFiles.count > Num Then
         colMRUFiles.Remove colMRUFiles.count
      End If
   End If

End Sub

Public Sub Clear()
   ' *** Clears all files from the list.

   Do While colMRUFiles.count > 0
      colMRUFiles.Remove 1
   Loop

End Sub

Public Property Get count() As Long
   ' *** Returns the number of files in the list.

   count = colMRUFiles.count

End Property


Public Property Get ITem(i As Integer) As String
   ' *** Returns the nth item from the list

   On Error GoTo ItemError
   ITem = colMRUFiles(i)
   Exit Property

ItemError:
   ITem = ""

End Property

Public Sub Load(Optional AppName As Variant)

   Dim v As Variant
   Dim i As Integer
   Dim j As Integer
   Dim AppN As String

   If IsMissing(AppName) Then
      AppN = App.ProductName
   Else
      AppN = CStr(AppName)
   End If

   v = GetAllSettings(AppN, "colMRUFiles")

   If Not IsEmpty(v) Then
      i = UBound(v, 1)
      Me.Clear
      colMRUFiles.Add v(i, 1), UCase(v(i, 1))

      For j = i - 1 To LBound(v, 1) Step -1
         colMRUFiles.Add v(j, 1), UCase(v(j, 1)), 1
      Next j
   End If

End Sub

Public Property Get Number() As Integer
   ' *** Gets the maximum size of the list.

   Number = Num

End Property

Public Property Let Number(i As Integer)
   ' *** Sets the maximum size of the list.

   Num = i

End Property

Public Sub Remove(file As String)

   On Error Resume Next
   colMRUFiles.Remove UCase(file)

End Sub

Public Sub Save(Optional AppName As Variant)

   Dim i As Integer
   Dim AppN As String

   On Error Resume Next

   If IsMissing(AppName) Then
      AppN = App.ProductName
   Else
      AppN = CStr(AppName)
   End If

   DeleteSetting AppN, "colMRUFiles"

   For i = 1 To colMRUFiles.count
      SaveSetting AppN, "colMRUFiles", i, colMRUFiles(i)
   Next i

End Sub

Public Sub Update(F As Form)
   ' *** Note:  The form must contain a menu control array
   ' ***        named mnuMRUFiles that is at least as big
   ' ***        as Number.

   Dim i As Long


   On Error GoTo NextStep
   For i = 1 To Num
      F.mnuMRUFiles(i).Visible = False
   Next i

NextStep:

   On Error GoTo MenuEnd
   If colMRUFiles.count > 0 Then
      F.mnuMRUFiles(0).Visible = True

      For i = 1 To colMRUFiles.count
         F.mnuMRUFiles(i).Caption = colMRUFiles(i)
         F.mnuMRUFiles(i).Visible = True
      Next i

      Do
         F.mnuMRUFiles(i).Visible = False
         i = i + 1
      Loop
   Else
      i = 0
      Do
         F.mnuMRUFiles(i).Visible = False
         i = i + 1
      Loop
   End If

MenuEnd:

End Sub

Private Sub Class_Initialize()

   Num = 10

End Sub


0
 

Author Comment

by:jfl
Comment Utility
Thanks!
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now