Question:
Printing of txt file thru VB?
pawan goel
2007-07-23 21:49:47 UTC
I had genetrate txt files from VB now i want to print that thru VB only. Can anybody suggest /send me the code.
Three answers:
anonymous
2007-07-23 22:47:09 UTC
Explain what you mean by print. Do you want to print the text files to the screen, or do you want to print them from a printer?



You can parse text files using the TextFieldParser object. Then you can print them onto the screen using System.Console.Write method.
dewman_byju
2007-07-24 08:07:00 UTC
Hi *

Open .txt files and print without fuss.

You need a form, three buttons, a common dialog control, and a rich text box.

Private Sub Command1_Click()



' The RichTextBox control is named "rtfData."

' The CommonDialog is named "dlgOpenFile."

' Declare a String variable for file name.

' Show the Open File dialog box, and set the

' variable to the filename.

Dim strOpen As String

CommonDialog1.ShowOpen

strOpen = CommonDialog1.filename

' Use LoadFile method to open the file.

RichTextBox1.LoadFile strOpen

End Sub



'To save a file is just as easy, using the SaveFile method:

Private Sub SaveFile()

Dim strNewFile As String

dlgOpenFile.ShowSave

strNewFile = dlgOpenFile.filename

rtfData.SaveFile strNewFile

End Sub



End Sub



Private Sub Command2_Click()

End

End Sub



Private Sub Command3_Click()



CommonDialog1.Flags = cdlPDReturnDC + cdlPDNoPageNums

If RichTextBox1.SelLength = 0 Then

CommonDialog1.Flags = CommonDialog1.Flags + cdlPDAllPages

Else

CommonDialog1.Flags = CommonDialog1.Flags + cdlPDSelection

End If

CommonDialog1.ShowPrinter

Printer.Print ""

RichTextBox1.SelPrint CommonDialog1.hDC

End Sub
?
2014-11-04 08:33:49 UTC
sophisticated step. seek into search engines like google. it could actually help!


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...