Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Where are the .bas, .frm, .vbp files?

Status
Not open for further replies.

jsteph

Technical User
Oct 24, 2002
2,562
US
Hi,
How do you tell *from within the VB6 environment* where the physical .bas, .frm, etc files are?

This is a very stupid question, I've been dealing with VB for years and have never really had this need, partially since a lot of my projects have used SourceSafe, partially because I've been very meticulous about making a folder for every project (and not putting them in the ...\VB98 folder as MS constantly defaults you to).

But months ago I had opened a project (not under source control), and removed a file, then added one of the same name from a different folder on a different machine. I now want to go and make a copy of the physical file. I've forgotten the folder. How do I find where it is? I can find nothing whatsoever that points, say clsXXX to say, C:\Projects\Someproject\clsXXX.cls. I know I can, say, make a change to it and do a search on recently modified, but I'm looking for something more reasonable.

I'm hoping it's something very elementary that I've just overlooked, but I can't seem to find this very simple information.
Thanks,
--Jim
 
You can have a search with windows default search "*.cls"
If you slightly remember the name then easy. You can also verify the created/modified date

________________________________________________________________________
Zameer Abdulla
Visit Me
By the time a man realizes that may be his father was right,
he usually has a son who says,
"Father, you are wrong!".
 
zmrAbdulla,strongm,
Thank you for replying. The .vbp file says nothing about file locations, at least not my copies. It has locations of some dll references, but no project files, only their names.

But further, I'm really looking for something *within the VB environment*, I would think this should be a basic, simple, and vital bit of information.

The windows Search thing, besides not being in the vb environment, isn't feasible also because the particular file I was looking for is on one of several servers, so I'd have to drag them all down doing a file search.

I was able to locate the file, but I was still wondering if that was possible to do within vb, I guess not?
--Jim
 
Well, then your vbp file is broken.

It contains all the information about where the component files of the project are located relative to the location vbp file. Of course, if those files are located in the same folder as the vbp file then you'll just see their names because there is no relative path.

Further, if there was something in the VB environment, I'd have given it to you as per your request. There isn't, I'm afraid. Except ...

... if you try and 'Save As...' each file of an open project, the default folder that comes up is the folder that the file was originally loaded from (as found in the vbp file)
 
strongm,
Yes, I've found that to be correct--that the vbp file will contain the full path only if it's in a different path than the vbp...in this case it was in the same path as the vbp which was on the server also.

So yes, that works, but it's still a pain. It'd be nice if it were in the Properties box, that seems like a logical place to me...
--Jim
 
Here, have some code I've just knocked together to make your life easier. You'll need to set references to the Microsoft Scripting Runtime and the Microsoft VBScript Regular Expression library
Code:
[blue]Option Explicit

Private Sub Command1_Click()
     Dim varIterate As Variant
    Dim strResults() As String
    strResults = GetProjectComponents("c:\program files\microsoft visual studio\vb98\MikeS\test2\project1.vbp") 'you'll need to put the path to the project file that you are interested in here
    
    For Each varIterate In strResults
        List1.AddItem varIterate
    Next
End Sub

' feed the full path of a VB project file to this function and get back a string array
' containing the paths to the component files
Private Function GetProjectComponents(ByVal strProjectFile As String) As String()
    Dim Components As Variant
    Dim Component As Variant
    Dim fso As FileSystemObject
    Dim RootPath As String
    Dim re As RegExp
    Dim myMatches As MatchCollection
    Dim myMatch As Match
    Dim strResult As String
    
    Components = Array("Form", "Module", "Class", "UserControl", "PropertyPage")
    Set fso = New FileSystemObject
    Set re = New RegExp
    re.Global = True
    re.MultiLine = True
    RootPath = fso.GetParentFolderName(strProjectFile)
    For Each Component In Components
        re.Pattern = "^" & Component & "=(.*?; )*(.*)"
        Set myMatches = re.Execute(fso.OpenTextFile(strProjectFile).ReadAll)
        For Each myMatch In myMatches
            strResult = strResult & fso.GetAbsolutePathName(fso.BuildPath(RootPath, myMatch.SubMatches(1)))
        Next
    Next
    GetProjectComponents = Split(strResult, vbCr)
End Function[/blue]
 
If you right click on the frm in the project explorer then select "Open Folder of File" then will take you to the folder and you can see the path. This may be a option of MzTools therefore you may want to install this free tool, if not for this for its many useful features. Also if you right click and select save as it should default to the folder in which the file is located.
 
>will take you to the folder and you can see the path

Which is no more advanced than the 'save as' trick we've already covered, and which you mention again
 
strongm,
oops sorry I must have overlooked that. :)
Tom
 
Thank you all for the tips, it has cleared things up. I guess in the end--although it'd be nice if it were in the properties box or somewhere else in the VB environment--this is the first time I've really been stumped looking for a file that I'd been working with. This information has been a good for learning and future reference. Thanks again,
--Jim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top