History Class

Cost
Free
Version
1

Readme

The history class is very simple to use. First, you need to add the class to your project, and declare a variable for each item. For example,

Dim clsFileHistory As clsHistory

When your application starts, you need to set the class properties, and initialize it:

Set clsFileHistory = New clsHistory
' specifies the key that the entries will be saved under
' in this case HKEY_CURRENT_USERSoftwareVB And VBA Program SettingssAppNamesKeysSection
' the text in red is the location where settings are saved using the standard SaveSetting function.
' the other text is the things you can change!
clsFileHistory.sAppName = App.Title 'change this to whatever you save the rest of the registry entries for your app
clsFileHistory.sSection = "History"
clsFileHistory.sKey = "FileHistory"
' specifies the maximum number of items.
' default is 10 (if you are happy with 10, you don't need to set it)
clsFileHistory.lMax = 8

To load the items from the registry, simply get the Items property which returns a collection. The following code adds all the recent files to cboFiles

Dim cItems As Collection
Dim i As Long
Set cItems = clsFileHistory.Items
cboFiles.Clear
For i = 1 To cItems.Count
    cboFiles.AddItem cItems(i)
Next

To add a new item to the list, use the AddItem command:

clsFileHistory.AddItem sFile 'sFile is the new item

If the item already exists, it is moved to the top. Once you have added the item, you will need to re-load the list. If you want to detect if and item is already on the list you can use the OnList function.

You might also like...

Comments

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“An expert is a man who has made all the mistakes that can be made in a very narrow field” - Niels Bohr