|
-
Mar 2nd, 2004, 03:37 AM
#1
Thread Starter
New Member
Avoiding Critical Errors Associated With Textfile Deletion - Solved
Hi,
I'd like to know two simple things.
1. How do I make linebreaks show up in a textfile? I have a button, for simplicity, call it "cmdTest". When a user clicks cmdTest, I'd like a textbox to fill with say, 2-3 lines of code, laid out one line after another, and then once the program is closed, I'd like that info saved to a textfile. The user will have already supplied the location of the file which I've retrieved using CommonDialog filter etc, so no problems there - my only problem is putting the info into the textbox with formatting so that the saved textfile looks/reads like this:
text here
text here
text here
text here
text here
What is wrong with the code I used:
txtExample.text = "text here" + Chr(13) + "text here" + Chr(13) + "text here"
I thought Chr(13) was a linebreak? 
2. How do you launch an application? I'd like to make a quick access panel of similar applications - the user will show the program where the different .exe's are and then hitting a command button will launch it. If I got the application path using commondialog, what's the code to launch an exe?
Thanks in advance all.
Last edited by Tyrell Zeon; Mar 2nd, 2004 at 10:05 PM.
-
Mar 2nd, 2004, 04:06 AM
#2
for the line problem you can do 2 things first:
Code:
text1.text = "aaa" & vbnewline & "bbb" & vbnewline & "ccc"
second:
Code:
print #1, "aaa"
print #1, "bbb"
print #1, "ccc"
This will automaticly print each string to a new line
And how to excecute a programm
Code:
shell("c:\myProg\Myprog.exe")
-
Mar 2nd, 2004, 05:57 AM
#3
Thread Starter
New Member
Thanks Lightning! That first method worked great. I haven't tried the exe launch just yet, that's later on in a different project.
One more quick question for anyone, associated with textfiles:
When reading in a textfile, I use this:
Const ForReading = 1
Dim fs, f
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.OpenTextFile(StoredFileNameandPathFromAnotherTime, ForReading)
Contents = f.ReadAll()
f.Close
If some clown deleted that textfile, it will cause the program to critical error which is bad design - what can I code in to avoid this crashout?
-
Mar 2nd, 2004, 06:42 AM
#4
Frenzied Member
Try something like this ....
VB Code:
if fs.fileexists("C:\test.doc") = true then
' file exists
else
' file doesn't exist
end if
-
Mar 2nd, 2004, 10:06 PM
#5
Thread Starter
New Member
Thanks BionicOrange that worked great, all my questions are answered now. I love these forums.
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
|