|
-
January 13th, 2000, 10:46 AM
#1
include a txt file
Hi,
Is it possible to "include" a txt file, let's say test.txt in my project.
I'm now opening a file for reading with:
Open "C:\project\program\test.txt" for input as #1
But I want to be able to open the file for reading without specifying to whole path, but just specify the filename only.
I'm asking this because my project will be copied several times and every time in a different directory.
Open "C:\project1\program\test.txt" for input as #1
Open "C:\project2\program\test.txt" for input as #1
Open "C:\project3\program\test.txt" for input as #1
When my project becomes very large with multiple files to be opened, I don't want to get errors and change the pathnames everytime for all the files.
Does anyone have I solution how I can handle this problem?
Thanx,
Maarten
-
January 13th, 2000, 11:18 AM
#2
Re: include a txt file
You can include the txt file in the setup package, so in your app you can use:
global filename as string
'in your sub
filename= app.path +"\"file name"
open filename .....
Something over there is coding....
... and you don't know!
-
January 13th, 2000, 09:36 PM
#3
Re: include a txt file
Ok for this code just test it and put it in a command button, just for testing, make 1 textbox named text1, make a commonddialog named commondialog1, and put this in for the command1's click procedure code:
'this lets you pick the txt file
CommonDialog1.Filter = "Text files (*.TXT)|*.TXT"
CommonDialog1.ShowOpen 'display Open dialog box
If CommonDialog1.FileName <> "" Then
Open CommonDialog1.FileName For Input As #1
On Error GoTo TooBig: 'set error handler
Do Until EOF(1) 'then read lines from file
Line Input #1, LineOfText$
AllText$ = AllText$ & LineOfText$ & Wrap$
Loop
text1.Text = AllText$ 'display file
text1.Enabled = True
mnuItemClose.Enabled = True
mnuItemOpen.Enabled = False 'enable scroll
CleanUp:
Form1.MousePointer = 0 'reset mouse
Close #1 'close file
End If
Exit Sub
TooBig: 'error handler displays message
MsgBox ("The specified file is too large.")
Resume CleanUp: 'then jumps to CleanUp routine
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|