Add To Recent v1.0
Submitted By:
flashboy01
Rating:
(Not rated) (
Rate It)
VERSION 5.00
Begin VB.Form frmTest
BorderStyle = 1 'Fixed Single
Caption = "Form1"
ClientHeight = 3060
ClientLeft = 150
ClientTop = 840
ClientWidth = 6660
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 3060
ScaleWidth = 6660
StartUpPosition = 3 'Windows Default
Begin VB.TextBox txtDelete
Height = 285
Left = 360
TabIndex = 7
Text = "0"
Top = 1920
Width = 1935
End
Begin VB.CommandButton buttDel
Caption = "Remove"
Height = 495
Left = 2400
TabIndex = 6
Top = 1680
Width = 1455
End
Begin VB.Frame Frame1
Caption = "Add to data"
Height = 1215
Left = 120
TabIndex = 0
Top = 240
Width = 6255
Begin VB.CommandButton buttSave
Caption = "Save"
Height = 495
Left = 4560
TabIndex = 5
Top = 480
Width = 1455
End
Begin VB.TextBox txtVal
Height = 285
Left = 840
TabIndex = 4
Top = 720
Width = 3615
End
Begin VB.TextBox txtName
Height = 285
Left = 840
TabIndex = 3
Top = 360
Width = 3615
End
Begin VB.Label Label2
Caption = "Value:"
Height = 255
Left = 240
TabIndex = 2
Top = 720
Width = 1815
End
Begin VB.Label Label1
Caption = "Name:"
Height = 255
Left = 240
TabIndex = 1
Top = 360
Width = 1815
End
End
Begin VB.Label Label4
Caption = "Please visit http://mysource.50webs.com/ for more of my VB projects"
BeginProperty Font
Name = "MS Sans Serif"
Size = 8.25
Charset = 238
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00400000&
Height = 255
Left = 120
MouseIcon = "frmTest.frx":0000
MousePointer = 99 'Custom
TabIndex = 9
Top = 2640
Width = 7095
End
Begin VB.Label Label3
Caption = "Remove item:"
Height = 375
Left = 360
TabIndex = 8
Top = 1680
Width = 1695
End
Begin VB.Menu mnuFile
Caption = "File"
Begin VB.Menu butt_mnuRecent
Caption = "Recent"
Begin VB.Menu buttRecent
Caption = "#"
Index = 0
End
End
End
End
Attribute VB_Name = "frmTest"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Declare Function ShellExecute Lib "Shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Private Const SW_NORMAL = 1
Private recent As New clsRecent
'remove item from recent items
Private Sub buttDel_Click()
recent.RemoveItem Int(Val(Me.txtDelete.Text))
recent.setMenu Me.buttRecent
End Sub
'show tag (data of recent item), button caption is
' recent item name
Private Sub buttRecent_Click(Index As Integer)
MsgBox Me.buttRecent(Index).Tag
End Sub
'add new item to recent
Private Sub buttSave_Click()
recent.AddItem Me.txtName.Text, Me.txtVal.Text
recent.setMenu Me.buttRecent
End Sub
'load item on form load
Private Sub Form_Load()
recent.MaxCount = 5 'number of recent items to display
recent.LoadFile App.Path & "\rec.txt"
'add items to control array buttRecent,
' class will do this (remove all items,and add new)
recent.setMenu Me.buttRecent
End Sub
'save items to file on form terminate
Private Sub Form_Terminate()
recent.SaveData App.Path & "\rec.txt"
Set recent = Nothing
End Sub
'this is no needed, class do this by calling
' setMenu sub
'Private Sub AddItems()
'
' Dim i As Integer
'
' For i = 1 To Me.buttRecent.Count - 1
'
' Unload Me.buttRecent(i)
'
' Next i
'
'
' For i = 0 To recent.ItemsCount - 1
'
' If i > 0 Then
' Load Me.buttRecent(i)
' Me.buttRecent(i).Visible = True
' End If
' Me.buttRecent(i).Caption = recent.Name(i)
' Me.buttRecent(i).Tag = recent.Data(i)
'
' Next i
'
'End Sub
Private Sub Label4_Click()
ShellExecute hwnd, "open", "http://mysource.50webs.com", vbNullString, vbNullString, SW_NORMAL
End Sub