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!

setting up a data input file as a resource file 1

Status
Not open for further replies.

damonh78

Programmer
Jul 28, 2005
44
IE
Hi,

Is this possible what I am trying to do. I have a file which my app reads from at initialisation to find the paths for certain directories. I have copied it below. Is the easiest way to make sure that the app can always find this file to read, so no matter where the app is installed the file will always be with it to have the file as a resource file.
I tried opening the resource editor and creating a custom resource file using my inout file. The problem is that if this is correct I have no idea how to read in the data from the resource file. Loadresdata only reads in bytes, I am looking for some way to read in lines at a time, as I would do if I was reading in normally from a file.

Is any of the above correct? If not what would be the best way of doing what i want to do?

Cheers,

John

Here is the inout file I was talking about:

#This file contains all the settings paths for the Database and Upload and Download
#directories. Any additional comments added in should be preceded by a # symbol.
#It would be wise to keep a copy of this file under a different name in case this version gets
#corrupted or changes somehow. When editing only edit the paths after the equals sign.
#Do not leave a gap between the path name and the equals sign and keep all data in the
#same order as it is here now.

#Database path + filename
Database-Directory=C:\Piper\Track.mdb

#upload directory
Upload-Directory=C:\Dan Stuff\upload

#Download Directory
Download-Directory=C:\Dan Stuff\Download
 
Once you read the byte data using LoadResData function, you can use the StrConv function to convert it to string format and then use string parsing functions to extract the desired data. See the following code.
___
[tt]
Dim V As Variant
V = StrConv(LoadResData(101, "Custom"), vbUnicode)
For Each V In Split(V, vbCrLf)
If Left$(V, 1) <> "#" And Trim$(V) <> "" Then
V = Split(V, "=")
Debug.Print "Name = " & V(0)
Debug.Print "Data = " & V(1)
Debug.Print
End If
Next[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top