I have a menu item that shows a list of file located in a directory. If I add or delete delete one of these files in the directory , and try to refresh the menu, it doesnt change. how would I go about doing this?
here is my current code
________________
Thanks!Code:Private Sub RefreshGroups()
Dim myArr() 'to hold the file names
Dim stFile As String
Dim idx As Integer
On Error GoTo Errortrap
stFile = Dir$(DataDir & "*.grp*") 'get all text files
idx = 1
Do While stFile <> ""
ReDim Preserve myArr(1 To idx)
mnuBarGroups(idx).Caption = stFile 'use the file name
stFile = Dir
idx = idx + 1
Loop
Errortrap:
Load mnuBarGroups(idx) 'build the menu
mnuBarGroups(idx).Caption = stFile
Exit Sub
________________________________________
Private Sub mnuBarGroups_Click(Index As Integer)
Dim fname As String
fname = DataDir & mnuBarGroups(Index).Caption
If fname = DataDir Then
Exit Sub
End If
Open fname For Random As #2
Dim contents As record
Dim X As Integer
'Adds each user in the file to list1
X = 1
Do Until EOF(2)
Get #2, X, contents
List1.AddItem contents.userid
X = X + 1
Loop
Close #2
End Sub
_________________________________________
Garrett
