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

how to add document to a vb project and reference it in code

Status
Not open for further replies.

gusset

Technical User
Mar 19, 2002
251
GB
i have just coded a database application. my sql strings are contained in .txt files and i read them as textstreams before passing them to the database. i want to distribute the application over an intranet but don't know how best to refer to the .txt files.

in development, i have simply used a reference to the files' path on my local machine but when the application is distributed as an .exe, there will be no common network drive.

i know that a document can be added to a project but don't know how i can refer to it in code. MSDN and textbooks have not yielded the answer - i am sure the answer is easy, but i don't know it!

thanks

gusset
 

Look in help for resource files. There should be an adequate instruction on how to create and use them.

Good Luck

 
You can get the files included in the distribution package via P&DW, keeping them in your application directory. Then you can refer to them in code using App.Path
________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'People who live in windowed environments shouldn't cast pointers.'
 
thanks, vb5prgrmr and johnwm. i don't have experience with either of those techniques, but they do look useful. i'll learn them one at a time.

vb5prgrmr, when i try to use my new resource file (with a .txt file in the hierarchy) i get "run-time error 326 resource with identifier '101' not found". yet the file is clearly there, with an id of 101.

i don't think its the way i'm referencing the file - txtTest.text = LoadResString(101).

any idea why this is happening, please?

thanks
 
i have been a bit stupid. in experimenting with adding a new resource file, i discovered that vb expects me to navigate to an existing one rather than creating one for me, so i renamed a .txt file as .res to see if that would be recognised. the interface suggested that it was recognised, which led me to think that i had created a resource file, but i don't think i have.

the documentation is not very clear on this point - any idea where i could go to find out more, please?

thanks

gusset
 
Have you tried this:

I asked Google for 'res file msdn vb6' to get there
________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'People who live in windowed environments shouldn't cast pointers.'
 
gusset, first u created one .txt file and later renamed it as .res file...that is wrong...
First u add resource editor tool(go to Add-Ins -> Add-In Manager..from that list select VB6 Resource Editor then check in Loaded/Unloaded in Load Behavior then click on OK)...
Now one green colour tool is added to ur tool bar(go to Project -> Add New Resource File)..By using this u can create new resource file. Try this
 
thanks, jincy.

now to add the resources...

the string tables are very easily referenced from code. they don't like line feeds, though, so i had to remove these as my SQL strings were prepared elsewhere.

i also discovered that you can add something called SQL scripts to a project - but the string table is easier for me as i'm just running a string in another application from code.



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top