topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Saturday April 27, 2024, 11:27 pm
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: Visual Basic 6 App.s in need of a way to list recent files used, ideas? Windows  (Read 4011 times)

OptimalDesigns

  • Supporting Member
  • Joined in 2018
  • **
  • Posts: 68
  • (retired) Mathematical Engineer
    • View Profile
    • Calculus (level) Problem Solving; Examples & Compiler
    • Read more about this member.
    • Donate to Member
An internet search came up with the following code.  How to use/implement it or use another way?
Also need more than 4 files saved as recent.  How to increase this to 'n' files?
Option Explicit
Dim i As Integer
Dim temp As String
Dim blnOnList As Boolean
 
Private Sub Form_Load()
    For i = 1 To 4
        mnuRegFile(i).Caption = GetSetting("MyProg", "filemenu", i, "")
        If mnuRegFile(i).Caption <> "" Then mnuRegFile(i).Visible = True
    Next
 
    If mnuRegFile(1).Visible = True Then mnuSep.Visible = True
End Sub
 
Private Sub mnuOpen_Click()
    Err.Clear
    On Error GoTo ErrHandle
    With CDlog
        .FileName = ""
        .Flags = cdlOFNFileMustExist + cdlOFNHideReadOnly
        .ShowOpen
    End With
    Open CDlog.FileName For Input As #1
    temp = Input(LOF(1), 1)
    Close #1
    txtTest.Text = temp
   
    AddRegList
 
    Exit Sub
 
ErrHandle:
    Close #1
    MsgBox Err.Description, vbCritical, "Open Error"
 
End Sub
 
Private Sub AddRegList()
    For i = 1 To 4
        mnuRegFile(i).Caption = GetSetting("MyProg", "filemenu", i, "")
    Next
   
    blnOnList = False                           'check if its already
    For i = 1 To 4
        If CDlog.FileName = mnuRegFile(i).Caption Then
            blnOnList = True
            Exit For
        End If
    Next                                        'on the list
   
    If blnOnList = True And i < 4 Then
        Select Case i
            Case 2
                mnuRegFile(2).Caption = mnuRegFile(1).Caption
                mnuRegFile(1).Caption = CDlog.FileName
            Case 3
                mnuRegFile(3).Caption = mnuRegFile(2).Caption
                mnuRegFile(2).Caption = mnuRegFile(1).Caption
                mnuRegFile(1).Caption = CDlog.FileName
        End Select
    Else
        mnuRegFile(4).Caption = mnuRegFile(3).Caption
        mnuRegFile(3).Caption = mnuRegFile(2).Caption
        mnuRegFile(2).Caption = mnuRegFile(1).Caption
        mnuRegFile(1).Caption = CDlog.FileName
    End If
   
    mnuRegFile(1).Visible = True
    mnuSep.Visible = True
    For i = 2 To 4
        If mnuRegFile(i).Caption <> "" Then mnuRegFile(i).Visible = True
    Next i
   
    For i = 1 To 4
        SaveSetting "MyProg", "filemenu", i, mnuRegFile(i).Caption
    Next i
End Sub
 
Private Sub mnuRegFile_Click(Index As Integer)
    Err.Clear
    On Error GoTo ErrHandle
    CDlog.FileName = GetSetting("MyProg", "filemenu", Index, "")
    Open CDlog.FileName For Input As #1
    temp = Input(LOF(1), 1)
    Close #1
    txtTest.Text = temp
   
    AddRegList
   
    Exit Sub
   
ErrHandle:
    Close #1
    MsgBox Err.Description, vbCritical, "Error"
End Sub
« Last Edit: April 22, 2023, 10:32 AM by OptimalDesigns »

KodeZwerg

  • Honorary Member
  • Joined in 2018
  • **
  • Posts: 718
    • View Profile
    • Donate to Member
Recent File List tipps for VB6.
From way of coding, you either having a fixed numbered menu list what you fill at runtime or an endless long one by having a method that adds menu items with content.

OptimalDesigns

  • Supporting Member
  • Joined in 2018
  • **
  • Posts: 68
  • (retired) Mathematical Engineer
    • View Profile
    • Calculus (level) Problem Solving; Examples & Compiler
    • Read more about this member.
    • Donate to Member
Recent File List tipps for VB6.
From way of coding, you either having a fixed numbered menu list what you fill at runtime or an endless long one by having a method that adds menu items with content.

Sorry you lost me ... i'm a math engineer trying to add a user's recent file names in order to make it simple to re-use them.