I am trying to make a setup program in VB6 that will install all the files that are required for the program.
I use a CSV file to store data and read it using:
file="C:\users\admin\desktop\table.csv"
Open file For Input As fnum
However the EXE file cannot be executed on another laptop as I get the error "file not found
".
So: how to embed this CSV document into the .EXE file so that the program can run on any Windows PC?
Open the project, Add-Ins menu item, open the Add-In manager & double click the VB6 Resource Editor to load it, close manager.
Click Project menu item then Add new Resource File at the bottom. Enter a file name for it & save it in the directory with your code files.
From the Project Explorer tree double click XXX.RES from the new Related Documents node.
Select Add Custom Resource from the toolbar in the window that pops up
Browse to your .csv and add it, you should see it added as CUSTOM\101
It will now be embedded into the exe at compile time. If the file changes, re-add it to the resource, there is a 64k limit per entry.
To load it in code at runtime:
strCSV = strconv(LoadResData(101, "CUSTOM"), vbunicode)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With