Results 1 to 12 of 12

Thread: [RESOLVED] Display text file in frame

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Nov 2009
    Posts
    16

    Resolved [RESOLVED] Display text file in frame

    I have a form and I want to display a text file inside a frame in the form ... Outside the frame , I want to give a print button pressing which we can print the text file ... Please help .... how can I do it ?? Thanks in Advance ....

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Display text file in frame

    Put a textbox in the frame, open the text file in the textbox then print the contents of the textbox.

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Nov 2009
    Posts
    16

    Re: Display text file in frame

    but how to open the file in a text box ?? I am using the datasource property but it is not working ...

  4. #4
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Display text file in frame

    No no...you don't need to use a property...write the code
    vb Code:
    1. Open "c:\rahulpgr.txt" For Input As #1    
    2.     Text1.Text = Input(LOF(1), 1)
    3. Close #1

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Nov 2009
    Posts
    16

    Re: Display text file in frame

    A problem is occurring ... the display is not same as in text file ... all lines are displayed in a single line and newline is displayed as ||

  6. #6
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Display text file in frame

    Set the Multiline to True in the textbox property page.

  7. #7
    PowerPoster Keithuk's Avatar
    Join Date
    Jan 2004
    Location
    Staffordshire, England
    Posts
    2,236

    Re: Display text file in frame

    Quote Originally Posted by rahulpqr View Post
    A problem is occurring ... the display is not same as in text file ... all lines are displayed in a single line and newline is displayed as ||
    Set the TextBox.MultiLine property to True.

    Oh you beat me Hack.
    Keith

    I've been programming with VB for 25 years. Started with VB4 16bit Pro, VB5 Pro, VB6 Pro/Enterprise and now VB3 Pro. But I'm no expert, I'm still learning.

  8. #8

    Thread Starter
    Junior Member
    Join Date
    Nov 2009
    Posts
    16

    Re: Display text file in frame

    Many Many thanks ... only one thing more ... can u plzz tell me what is the meaning of LOF(1),1 in the parameter of input .... and can you plzz give me the code of print button ?? Thanks again .

  9. #9
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Display text file in frame

    LOF = Length Of File

  10. #10

    Thread Starter
    Junior Member
    Join Date
    Nov 2009
    Posts
    16

    Re: Display text file in frame

    Thank you very much ... can You give me the code of print button ?? I am very grateful to you for giving your valuable time to me . Thanks again.

  11. #11
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Display text file in frame

    Here is a reusable print function
    vb Code:
    1. Private Function PrintTextFile(sTextFile As String) As String
    2. If Dir(sTextFile) <> vbNullString Then
    3.     Open sTextFile For Binary As #1
    4.     PrintTextFile = Input(LOF(1), 1)
    5.     Close #1
    6. End If
    7. End Function
    8.  
    9. Private Sub Command1_Click()
    10. Screen.MousePointer = vbHourglass
    11. Printer.Print PrintTextFile("c:\rahulpqr.txt")
    12. Printer.EndDoc
    13. Screen.MousePointer = vbDefault
    14. End Sub

  12. #12

    Thread Starter
    Junior Member
    Join Date
    Nov 2009
    Posts
    16

    Re: [RESOLVED] Display text file in frame

    Thanku Thanku Thanku .......... My problems are resolved

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