|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Add a document to my project?document is fairly long so I read it in from a file at run-time by doing:- Open App.Path & "\MyFile.txt" For Input As #FileNumber .... etc This is much easier than me converting the document to a long string in VB as this would take ages to convert to:- MyString = MyString & "Some sample text " & vbCrLf & _ "More sample text" .... etc Plus my document often changes (each time I do a new version of my project), so reading the file in at run-time is a much quicker process. However I would like to know whether it is possible to import the whole document into the project and simply read the contents of this when I run the project. This would mean I would not have to distribute a seperate file. Is something like this possible? Thanks One way to do this would be to add your file to a resource file as a "Custom
Resource". Note that VB will store the file as unicode so you have to convert it back when the file is retrieved. So for a custom resource called "101" this will extract the file: (untested air code) FileInAString = StrConv(LoadResData("101", "CUSTOM"), vbUnicode) Regards Dave O. Show quoteHide quote "Chris" <cw@community.nospam> wrote in message news:%23GjfjUw0FHA.1168@TK2MSFTNGP10.phx.gbl... > I've got a text document which I display in a text box in my project. The > document is fairly long so I read it in from a file at run-time by doing:- > > Open App.Path & "\MyFile.txt" For Input As #FileNumber > ... etc > > This is much easier than me converting the document to a long string in VB > as this would take ages to convert to:- > > MyString = MyString & "Some sample text " & vbCrLf & _ > "More sample text" > ... etc > > Plus my document often changes (each time I do a new version of my > project), so reading the file in at run-time is a much quicker process. > However I would like to know whether it is possible to import the whole > document into the project and simply read the contents of this when I run > the project. This would mean I would not have to distribute a seperate > file. Is something like this possible? > > Thanks >
Show quote
Hide quote
> I've got a text document which I display in a text box in my project. The Have a look at using a resource file, then use LoadResData() or > document is fairly long so I read it in from a file at run-time by doing:- > > Open App.Path & "\MyFile.txt" For Input As #FileNumber > ... etc > > This is much easier than me converting the document to a long string in VB > as this would take ages to convert to:- > > MyString = MyString & "Some sample text " & vbCrLf & _ > "More sample text" > ... etc > > Plus my document often changes (each time I do a new version of my > project), so reading the file in at run-time is a much quicker process. > However I would like to know whether it is possible to import the whole > document into the project and simply read the contents of this when I run > the project. This would mean I would not have to distribute a seperate > file. Is something like this possible? LoadResString (depending on what format the document is in) at runtime to load it. Hope this helps, Mike - Microsoft Visual Basic MVP - E-Mail: ED***@mvps.org WWW: Http://EDais.mvps.org/ On Mon, 17 Oct 2005 11:25:44 +0100, "Chris" <cw@community.nospam> <snip>wrote: >This would mean I would not have to distribute a seperate file. Is There is a very neat old fashioned trick that works very nicely>something like this possible? Append the text file to the end of the EXE with a footer describing it in the last few bytes. While developing read it in from a file into one long string When compiled write a utility (maybe in the App) that appends the file to a new copy of the EXE.
Show quote
Hide quote
"J French" <erew***@nowhere.uk> wrote in message A minor point, but Be aware while developing and especially on a targetnews:4354af7d.242352704@news.btopenworld.com... > On Mon, 17 Oct 2005 11:25:44 +0100, "Chris" <cw@community.nospam> > wrote: > > <snip> > > >This would mean I would not have to distribute a seperate file. Is > >something like this possible? > > There is a very neat old fashioned trick that works very nicely > > Append the text file to the end of the EXE with a footer describing it > in the last few bytes. > > While developing read it in from a file into one long string > > When compiled write a utility (maybe in the App) that appends the file > to a new copy of the EXE. > machine, that 'modifying' the .exe will drive some realtime VirusCheckers nuts. <g> -ralph On Tue, 18 Oct 2005 10:11:19 -0500, "Ralph"
<nt_consultin***@yahoo.com> wrote: <snip> >> When compiled write a utility (maybe in the App) that appends the file Very true >> to a new copy of the EXE. >A minor point, but Be aware while developing and especially on a target >machine, that 'modifying' the .exe will drive some realtime VirusCheckers >nuts. <g> >-ralph - but little will work on a development machine with that stuff activated
Show quote
Hide quote
"J French" <erew***@nowhere.uk> wrote in message I should have said a very, very, minor point, but I felt worth mentioning,news:43551b76.269997725@news.btopenworld.com... > On Tue, 18 Oct 2005 10:11:19 -0500, "Ralph" > <nt_consultin***@yahoo.com> wrote: > > <snip> > > >> When compiled write a utility (maybe in the App) that appends the file > >> to a new copy of the EXE. > > >A minor point, but Be aware while developing and especially on a target > >machine, that 'modifying' the .exe will drive some realtime VirusCheckers > >nuts. <g> > > >-ralph > > Very true > - but little will work on a development machine with that stuff > activated > as depending on the VirusChecker used and its configuration, subsequent problems can be rather puzzling the first time you run across it. -ralph On Tue, 18 Oct 2005 13:35:13 -0500, "Ralph"
<nt_consultin***@yahoo.com> wrote: <snip> >> Very true Understood - the main thing is that this would all be run on a>> - but little will work on a development machine with that stuff >> activated >I should have said a very, very, minor point, but I felt worth mentioning, >as depending on the VirusChecker used and its configuration, subsequent >problems can be rather puzzling the first time you run across it. development machine. I have to confess that I've little faith in virus checkers - idiot users install malware regardless - also viruse are always ahead of the checkers (unless, as some suspect, the viruse come from the virus checkers)
Show quote
Hide quote
"J French" <erew***@nowhere.uk> wrote in message Funny you should mention that. VirusCheckers and their ilk are the newnews:4356360e.3969534@news.btopenworld.com... > On Tue, 18 Oct 2005 13:35:13 -0500, "Ralph" > <nt_consultin***@yahoo.com> wrote: > > <snip> > > >> Very true > >> - but little will work on a development machine with that stuff > >> activated > > > >I should have said a very, very, minor point, but I felt worth mentioning, > >as depending on the VirusChecker used and its configuration, subsequent > >problems can be rather puzzling the first time you run across it. > > Understood - the main thing is that this would all be run on a > development machine. > > I have to confess that I've little faith in virus checkers > - idiot users install malware regardless > - also viruse are always ahead of the checkers > (unless, as some suspect, the viruse come from the virus checkers) > target. And guess who is the worse at protecting themselves - Norton/Symantec. But then I guess that doesn't really surprise anyone. <g> -ralph Thanks for all the replies.
Chris Show quoteHide quote "Chris" <cw@community.nospam> wrote in message news:%23GjfjUw0FHA.1168@TK2MSFTNGP10.phx.gbl... > I've got a text document which I display in a text box in my project. The > document is fairly long so I read it in from a file at run-time by doing:- > > Open App.Path & "\MyFile.txt" For Input As #FileNumber > ... etc > > This is much easier than me converting the document to a long string in VB > as this would take ages to convert to:- > > MyString = MyString & "Some sample text " & vbCrLf & _ > "More sample text" > ... etc > > Plus my document often changes (each time I do a new version of my > project), so reading the file in at run-time is a much quicker process. > However I would like to know whether it is possible to import the whole > document into the project and simply read the contents of this when I run > the project. This would mean I would not have to distribute a seperate > file. Is something like this possible? > > Thanks > To read the entire file into a string variable, use the following:
MyString = String(LOF(FileNumber), 0) Get FileNumber, , MyString Show quoteHide quote "Chris" <cw@community.nospam> wrote in message news:%23GjfjUw0FHA.1168@TK2MSFTNGP10.phx.gbl... > I've got a text document which I display in a text box in my project. The > document is fairly long so I read it in from a file at run-time by doing:- > > Open App.Path & "\MyFile.txt" For Input As #FileNumber > ... etc > > This is much easier than me converting the document to a long string in VB > as this would take ages to convert to:- > > MyString = MyString & "Some sample text " & vbCrLf & _ > "More sample text" > ... etc > > Plus my document often changes (each time I do a new version of my > project), so reading the file in at run-time is a much quicker process. > However I would like to know whether it is possible to import the whole > document into the project and simply read the contents of this when I run > the project. This would mean I would not have to distribute a seperate > file. Is something like this possible? > > Thanks >
3D Array from String
Find all child processes Help with VB6 Collection Classes OT: Post Programming Depression File Security Descriptor VB Runtime error 5 Conversion of character to hexadecimal Newbie: Find if a file exists rdo: "run-time error '429': ActiveX component can't create object" Hep with SQL |
|||||||||||||||||||||||