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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hardcoded Server Path

Status
Not open for further replies.

ghost2

Programmer
Aug 7, 2003
145
US
Hello all. How can I eliminate a hardcoded server path that resides in a class module in my VB application?
 
Don't harcode it? Maybe store the path in an outside file or in the registry?

--
Jonathan
 
There are multilple ways. You could use a registry setting, an Ini file,a database entry, or use a Common Dialog box to name a few.

If you choose to battle wits with the witless be prepared to lose.

[cheers]
 
ghost2

I pass the path from the shortcut. Here is some unworthy code that works for me.

Short cut
---------

\\sname\fname\app.exe \\sname\fname\subfname\db.mdb

Form Load
---------

dbpath = Command 'dbpath is a global variable


Sub Procedure
-------------

Dim myArray() As String
Dim iarray As Integer
Dim strReportAppPath As String

myArray = Split(dbpath, "\")

For iarray = 0 To UBound(myArray) - 1 'don't want last cell
'which contains name of main database

If Trim$(myArray(iarray)) <> &quot;&quot; Then
strReportAppPath = strReportAppPath & myArray(iarray) & &quot;\&quot;
Else
strReportAppPath = strReportAppPath & &quot;\&quot;
End If

Next iarray



 
Thanks all. So lets say I have multiple VB apps that need to access the same SQL database. What would you suggest would be the best way?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top