Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Remember the latest 10 folders that I have opened

Posted on 1998-08-26
2
135 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
String manipulation in Visual Basic 7 72
VB6 - Compare and highlight cell not the same 3 53
MS Date Picker 64 bit 32 bit issue 12 59
VBA Shell can't Find Word document 11 110
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

809 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