Example of MRU displaying in a combo box

Is there a way to find out the last 10 books I viewed like an MRU procedure in a combo box.

Examples are appreciated if it relates to combo box use much better
zachvaldezAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

mladenoviczCommented:
You should have an array or collection that represents MRU. When you start app you should read it from file (txt, ini, xml, ...). When you open a book you should add it to the MRU. When you close app you should save MRU to the file. You can easy populate combo from array or collection
0
JR2003Commented:
See http://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/Q_21101774.html
for something similar

As you use the combo when you add another item to the combo just do a check of Combo1.ListCount
If it's greater than 10 remove the 10th item (item 9)

    With Combo1
        If .ListCount > 10 Then
            .RemoveItem 9
        End If
    End With
0
zachvaldezAuthor Commented:
mladenovicz,
That may be a great idea. Please send me example code of your approach/recommendation.

Thanks
0
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

zachvaldezAuthor Commented:
I'd like to see an ex. to read and write to an ini or text file..The example JR2003 sent me was excellent but i'd like to save the values entered in the combo box in an ini  file/text file so I can retrieve it to know the last 10 MRU's items.

Thanks
0
JR2003Commented:
The standard place to store this information for use next time is in the registry

In your form load and unload event you should have something like this:

Private Sub Form_Load()

    Dim i As Long
    Dim sBookName As String
   
    Combo1.Clear 'Initialsie
    For i = 1 To 10
        sBookName = GetSetting(App.Title, Me.Name, "MRUBook" & i, "")
        If sBookName <> "" Then
            Combo1.AddItem sBookName
        End If
    Next i

End Sub


Private Sub Form_Unload(Cancel As Integer)

    Dim i As Long
    Dim sBookName As String
    For i = 0 To Combo1.ListCount - 1
        sBookName = Combo1.List(i)
        SaveSetting App.Title, Me.Name, "MRUBook" & i + 1, sBookName
    Next i
    For i = Combo1.ListCount To 10
        SaveSetting App.Title, Me.Name, "MRUBook" & i + 1, ""  'Remove any old ones which may no longer be required
    Next i

End Sub
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
JR2003Commented:
That last bit should have + 1 in it i.e.:

 For i = Combo1.ListCount + 1 To 10
        SaveSetting App.Title, Me.Name, "MRUBook" & i + 1, ""  'Remove any old ones which may no longer be required
    Next i
0
zachvaldezAuthor Commented:
Thanks again JR2003,
  I would like to know this time to how to display the 10 books from the registry in a notepad or text file.
Can I disply it in a text file so I can more or less confirm the top 10 are there/exist?
0
JR2003Commented:
Run regedit. (Go in to Start, Run then just type regedit)
 
Look under
HKEY_CURRENT_USER\Sotware\VB and VBA Program Settings

There should be a key under there which will be taken from your App.Title (e.g. Project1)
In there there's another key which is your form name (e.g. Form1)
In there are the MRUBook1...MRUBook10 values.
0
zachvaldezAuthor Commented:
While doing this anyhow, I still wanted to display more than 10 items in the listbox. So in order to differentiate the top ten MRUs,I'd prefer to highlight those items in the combo box to  to green> Is that possible? Thanks
0
JR2003Commented:
I don't think it's possible, perhaps you should start a new question on how to make items green in a listbox/combobox. You could use a ListView control and colour individual items though.

You can save more then 10 items in the registry, in fact you can save as many items as you like. Just adjust the  For loops in the code above:
 For i = 1 To ???

0
zachvaldezAuthor Commented:
That's great!!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.