-
In a lot of VB code samples I see, paths for icons, graphics, databases, etc., are "hard-coded" into the control at design-time ("i.e. C:\VB6\Biblio.mdb").
But if the user decides to install the program on the D: drive, this will be a major problem. What's the right way to make sure your program will find its files no matter what drive or folder the user decides to install in?
-
This code returns the path of the exe file.
-
Boy that was easy! Thanks!
-
Look up "App.Path" in VB help:
Code:
'App Path to open Database
'Set database name
Dim cDBName As String
cDBName = App.Path + "\SomeDataBase.mdb"
'Open db for exclusive use to see if anyone using it
Dim dbName As Database ' database object
Set dbName = OpenDatabase(cDBName, True)
'you would use similiar routines for files, pictures, etc.