Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
 
MSDN Visual Basic Community
 
 
 
 
 
 
TitleDetermine what FRM, BAS, OCX, and CLS files a project file references
DescriptionThis example shows how to determine what FRM, BAS, OCX, and CLS files a project file references in Visual Basic 6. It opens the VBP file and looks for the referenced file names.
KeywordsVBP, files
CategoriesStrings, Files and Directories
 
The program reads the VBP file one line at a time looking for lines that end with .FRM, .BAS, .CLS, or .OCX. It parses the file names out of those lines and adds them to the appropriate list.
 
Private Sub Command1_Click()
Dim file_num As Integer
Dim file_name As String
Dim file_line As String
Dim ext As String
Dim pos As Integer

    On Error Resume Next

    FileDialog.ShowOpen
    If Err.Number Then Exit Sub
    file_num = FreeFile()
    file_name = FileDialog.FileTitle

    Open file_name For Input As file_num

    FrmFiles.Clear
    BasFiles.Clear
    OcxFiles.Clear
    ClsFiles.Clear
    Do While Not EOF(file_num)
        ' Read the next line from the file.
        Line Input #file_num, file_line
        file_line = Trim$(file_line)

        ' Read the extension from the end
        ' of the line.
        ext = UCase$(Right$(file_line, 4))
        Select Case ext
            Case ".FRM"
                pos = InStr(file_line, "=")
                file_name = Trim$(Mid$(file_line, pos + 1, _
                    Len(file_line) - pos))
                FrmFiles.AddItem file_name
            Case ".BAS"
                pos = InStr(file_line, ";")
                file_name = Trim$(Mid$(file_line, pos + 1, _
                    Len(file_line) - pos))
                BasFiles.AddItem file_name
            Case ".CLS"
                pos = InStr(file_line, ";")
                file_name = Trim$(Mid$(file_line, pos + 1, _
                    Len(file_line) - pos))
                ClsFiles.AddItem file_name
            Case ".OCX"
                pos = InStr(file_line, ";")
                file_name = Trim$(Mid$(file_line, pos + 1, _
                    Len(file_line) - pos))
                OcxFiles.AddItem file_name
        End Select
    Loop
    Close file_num
End Sub
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated