Introduction
This class automatically creates recent menu items. This class is very easy to use and is very useful. You only need to create a menu button
(with index 0 to define a control array), define a file for saving recent items, and when you want, call the AddItem
method. The class will automatically create all the menu buttons,
delete the old buttons, set the button captions with item names, and button tag properties with item data values. You can also set
the maximum count of recent items, and when you add items that already exist, the class will delete the old item and set the new items at the start (so it will be first on the list).
How to use
It is very easy to use this class. You just need to add this class to your project, define the maximum number of recent items (default is 5), create a menu button (with index 0 to define
the control array), and that is all.
Functions / subs
AddItem(ByVal str_name As String, ByVal str_data As String)
– insert new recent item with name str_name
and value str_data
Data(ByVal Index As Integer) As String
– return recent item data (value)
Name(ByVal Index As Integer) As String
– return recent item name
LoadFile(ByVal str_file As String) As Boolean
– load recent items from file; if failed, return false
RemoveItem(ByVal Index As Integer)
– delete recent item
SaveData(ByVal str_file As String)
– save recent items to file
SetMenu(ByRef objMenu As Object)
– create menu items
Example (code for using recent items)
Private Sub buttRecent_Click(Index As Integer)
MsgBox Me.buttRecent(Index).Tag
End Sub
Private Sub buttSave_Click()
recent.AddItem Me.txtName.Text, Me.txtVal.Text
recent.setMenu Me.buttRecent
End Sub
Private Sub Form_Load()
recent.MaxCount = 5 recent.LoadFile App.Path & "\rec.txt"
recent.setMenu Me.buttRecent
End Sub
Private Sub Form_Terminate()
recent.SaveData App.Path & "\rec.txt"
Set recent = Nothing
End Sub