Results 1 to 11 of 11

Thread: Opening Txt File

  1. #1

    Thread Starter
    Hyperactive Member PITBULLCJR's Avatar
    Join Date
    Nov 1999
    Location
    New York
    Posts
    408

    Talking

    Say you create your own notepad. Then you go and assocaite .txt files with your program so now when you open a txt file it runs your program. How do you get your program to open that file and put it in the richtextbox? Thanks!!
    Sincerely,
    Chris


    Email: [email protected]
    AIM: KnightsOfTheMoon
    WebPage: http://kom.wicre.com
    ----------------
    VB6 Professional
    Abit ST6-RAID
    1000 MHZ
    512 MB PC133 Ram
    Nvidia GeForce 2 Ultra 64 MB
    Maxtor 81.9 Gig
    Win 98 SE

  2. #2
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Code:
    RichTextBox1.LoadFile "myfile.txt", rtfText
    Use rtfRTF to load a Rich Text File.
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  3. #3

    Thread Starter
    Hyperactive Member PITBULLCJR's Avatar
    Join Date
    Nov 1999
    Location
    New York
    Posts
    408
    Yes, I know how to open a file like that. But if someone double clicks on a txt file and your program starts up you don't know the name of that file. So you can't load it that way. Any other suggestions? Thanks!!
    Sincerely,
    Chris


    Email: [email protected]
    AIM: KnightsOfTheMoon
    WebPage: http://kom.wicre.com
    ----------------
    VB6 Professional
    Abit ST6-RAID
    1000 MHZ
    512 MB PC133 Ram
    Nvidia GeForce 2 Ultra 64 MB
    Maxtor 81.9 Gig
    Win 98 SE

  4. #4
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    The filename will be supplied to your program as part of the Command item:
    Code:
    RichTextBox1.LoadFile Command, rtfText
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  5. #5

    Thread Starter
    Hyperactive Member PITBULLCJR's Avatar
    Join Date
    Nov 1999
    Location
    New York
    Posts
    408

    Thumbs up *SMILES*

    Thanks it worked great. Now that I know it can be done its time to make my own personal notepad the way I like it. Thanks man!!
    Sincerely,
    Chris


    Email: [email protected]
    AIM: KnightsOfTheMoon
    WebPage: http://kom.wicre.com
    ----------------
    VB6 Professional
    Abit ST6-RAID
    1000 MHZ
    512 MB PC133 Ram
    Nvidia GeForce 2 Ultra 64 MB
    Maxtor 81.9 Gig
    Win 98 SE

  6. #6
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    One thing to keep in mind, if someone calls your program like:
    Code:
    myprog.exe afile.txt
    then it will work fine. Unfortunately, if they add any other options, it won't:
    Code:
    myprog.exe afile.txt /opt:5
    Your program will then try and load the file: "afile.txt /opt:5", and will die. You'd need to find some way of splitting the string up.
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  7. #7

    Thread Starter
    Hyperactive Member PITBULLCJR's Avatar
    Join Date
    Nov 1999
    Location
    New York
    Posts
    408
    What are those option things? I have never seen them before and have no idea what they do?
    Sincerely,
    Chris


    Email: [email protected]
    AIM: KnightsOfTheMoon
    WebPage: http://kom.wicre.com
    ----------------
    VB6 Professional
    Abit ST6-RAID
    1000 MHZ
    512 MB PC133 Ram
    Nvidia GeForce 2 Ultra 64 MB
    Maxtor 81.9 Gig
    Win 98 SE

  8. #8
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    They can do anything you want your program to do. For example, if you wanted it to print the file, without showing it, you could have a /p option.
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  9. #9

    Thread Starter
    Hyperactive Member PITBULLCJR's Avatar
    Join Date
    Nov 1999
    Location
    New York
    Posts
    408
    Well I have no idea how to use them so my prog won't be able to do that for a while atleast. Thanks anyway!!
    Sincerely,
    Chris


    Email: [email protected]
    AIM: KnightsOfTheMoon
    WebPage: http://kom.wicre.com
    ----------------
    VB6 Professional
    Abit ST6-RAID
    1000 MHZ
    512 MB PC133 Ram
    Nvidia GeForce 2 Ultra 64 MB
    Maxtor 81.9 Gig
    Win 98 SE

  10. #10
    Guest
    This will disregard anything after the filename.
    Code:
    RichTextBox1.LoadFile Left(Command$, InStr(1, Command$, ".") + 3), rtfText

  11. #11
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Megatron - that's fine until they use long filenames - the filename will be enclosed in quotes (it should anyway). I'll have a go at sorting something else out.
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

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