Results 1 to 6 of 6

Thread: How to show a txt file

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jan 2006
    Posts
    21

    How to show a txt file

    Hi

    In my program I am editing a text file and I want it to open at the end so that I can see it. How can I do that ??

    Thanks

  2. #2
    Member
    Join Date
    Mar 2006
    Posts
    52

    Re: How to show a txt file

    You mean like open it in a textbox?

    sample:

    VB Code:
    1. 'put one textbox on the form named Text1
    2. 'make it multiline
    3. 'put one common dialog control on the form
    4. 'name it dlgMain
    5.  
    6. Private Sub form_load()
    7. dlgMain.showOpen
    8. dim file as integer
    9. file = FreeFile
    10. open dlgMain.FileName for input as file
    11. Text1.Text = Input$(LOF(file), file)
    12. close file
    13. end sub

    I think that should work.

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Jan 2006
    Posts
    21

    Re: How to show a txt file

    I mean just open it with WordPad.

  4. #4
    Member
    Join Date
    Mar 2006
    Posts
    52

    Re: How to show a txt file

    ??
    well if you write the file, WordPad can open it.

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Jan 2006
    Posts
    21

    Re: How to show a txt file

    can't it just pops-up by itself ?

  6. #6
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: How to show a txt file

    VB Code:
    1. Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" ( _
    2.                 ByVal hwnd As Long, _
    3.                 ByVal lpOperation As String, _
    4.                 ByVal lpFile As String, _
    5.                 ByVal lpParameters As String, _
    6.                 ByVal lpDirectory As String, _
    7.                 ByVal nShowCmd As Long) As Long
    8.  
    9. Private Const SW_SHOWNORMAL As Long = 1
    10.  
    11. Private Sub Form_Load()
    12.     ShellExecute Me.hwnd, "Open", "C:\file.txt", vbNullString, vbNullString, SW_SHOWNORMAL
    13. End Sub
    will open it with the default program for the user

    to open it in notepad:

    VB Code:
    1. Shell "notepad.exe " & Chr$(34) & "C:\file.txt"& Chr$(34)

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