Results 1 to 5 of 5

Thread: Avoiding Critical Errors Associated With Textfile Deletion - Solved

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2004
    Location
    United Kingdom
    Posts
    3

    Question 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.

  2. #2
    Frenzied Member Lightning's Avatar
    Join Date
    Oct 2002
    Location
    Eygelshoven
    Posts
    1,611
    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")
    VB6 & C# (WCF LINQ) mostly


    If you need help with a WPF/WCF question post in the NEW WPF & WCF forum and we will try help the best we can

    My site

    My blog, couding troubles and solutions

    Free online tools

  3. #3

    Thread Starter
    New Member
    Join Date
    Mar 2004
    Location
    United Kingdom
    Posts
    3
    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?

  4. #4
    Frenzied Member TheBionicOrange's Avatar
    Join Date
    Apr 2001
    Location
    Cardiff, UK
    Posts
    1,818
    Try something like this ....

    VB Code:
    1. if fs.fileexists("C:\test.doc") = true then
    2. ' file exists
    3. else
    4. ' file doesn't exist
    5. end if

  5. #5

    Thread Starter
    New Member
    Join Date
    Mar 2004
    Location
    United Kingdom
    Posts
    3
    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
  •  



Click Here to Expand Forum to Full Width