Solved

Remember the latest 10 folders that I have opened

Posted on 1998-08-26
2
133 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
ID: 1431059
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
ID: 1431060
Thanks!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

919 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

21 Experts available now in Live!

Get 1:1 Help Now