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 ....
Printable View
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 ....
Put a textbox in the frame, open the text file in the textbox then print the contents of the textbox.
but how to open the file in a text box ?? I am using the datasource property but it is not working ...
No no...you don't need to use a property...write the codevb Code:
Open "c:\rahulpgr.txt" For Input As #1 Text1.Text = Input(LOF(1), 1) Close #1
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 Multiline to True in the textbox property page.
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 .
LOF = Length Of File
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.
Here is a reusable print functionvb Code:
Private Function PrintTextFile(sTextFile As String) As String If Dir(sTextFile) <> vbNullString Then Open sTextFile For Binary As #1 PrintTextFile = Input(LOF(1), 1) Close #1 End If End Function Private Sub Command1_Click() Screen.MousePointer = vbHourglass Printer.Print PrintTextFile("c:\rahulpqr.txt") Printer.EndDoc Screen.MousePointer = vbDefault End Sub
Thanku Thanku Thanku .......... My problems are resolved