Joke Collection Website - Cold jokes - In vb, what should I do if I can't connect to the virtual printer with Open LPT1 For Output As #1? The prompt file is not found!
In vb, what should I do if I can't connect to the virtual printer with Open LPT1 For Output As #1? The prompt file is not found!
1. when using the simple print function PrintForm method provided by Visual Basic
the PrintForm method of application form? Visual Basic sends the bitmap of the current form to the printer. The advantage of this method is that it hardly needs any programming? But it also has great defects. The most prominent is when low-resolution graphics are printed on high-resolution printers? The result is unsatisfactory? It will produce serrations.
the code is as follows:
Private Sub Command1_Click? Print
me. PrintForm' prints the visible area of the form
End Sub
2. Use the Printer object
to produce complex printouts? Programming is cumbersome. The Printer object represents the default printer of the system? The Printer object supports many properties and methods supported by forms and graphic boxes? All three objects have lines and boxes. The application can draw a 1-inch square box on the Printer object with the following code. Attention? The printer measures the distance in twips. There are 144 twips per inch.
Printer.Line? 2? 144? 2? 144 -Step? 144? 144 B
Printers, slave forms and graphic boxes all have Circle, PaintPicture, print, Pset, TextHeight and TextWidth methods. Use these methods? Applications can generate high-resolution output for printers.
Print text directly, see the following code:
Printer.Print "Hello? China ComputerWorld?" There is no way to print the string
Printer object and some forms and graphic boxes?
NewPage told the printer? Has the program finished sending the current output page? The Printer object should start a new page.
EndDoc told VB? End of program creation document? VB should send it to a physical printer for printing.
KillDoc cancels the current print job. The application should terminate each print job set by EndDoc and KillDoc.
the zoom attribute is used to define the zoom factor of the printout.
the copies property is used to define the number of copies to be printed.
3. if you use RichTextBox control when programming? Then you can use the SelPrint method of the control to print the
code as follows:
Private Sub Command3_Click? SelPrint method
commondialog1.flags = cdlpdreturndc+
cdlpdnopagenums
ifrtf1.sellength = then' rtf1 is the RichTextBox control of the form
CommonDialog1.Flags = Common. Dialog1.Flags+ cdlPDAllPages
Else
CommonDialog1.Flags = CommonDialog1.Flags+ cdlPDSelection
End If
CommonDialog1.CancelError = True
On Error Resume Next
CommonDialog1.ShowPrinter
If Err.Number = cdlCancel Then Exit Sub
If Err.Number < > Then
Beep
MsgBox "Error printing file." & vbCrLf + Err.Description? vbOKOnly +vbExclamation? "Printing Error?"
exit sub
end if
printer.print ""
RTF1.selprint common dialog1.hdc' print the visible area of rtf1 control
End Sub
and set the code first? Then print. If you don't need to set it? Is it easier to use the following code?
RTF1.SelPrint Printer.hDC' print the visible area of RTF1 control
4. Can you call the OLE automation service provided by Word 97 in VB? Use the powerful printing function of Word 97 to complete VB printing
the code is as follows:
Private Sub Command4_Click? Call Word to print
dim obj word as object
const classobject = "word. application"
on error goto obj error
set obj word = createobject? CLASSOBJECT
objWord.Visible = True
objWord.Documents.Add
With objWord
.ActiveDocument.Paragraphs.Last.Range.Bold = False
.ActiveDocument.Par A graphs. last.range.font.size = 2
. activedocument.paragraphs.last.range.font.name = "bold"
. activedocument.paragraphs.last.range.font.colorindex = = 4
. activedocument.paragraphs.last.range.text = "Am I a computer world reader?"
end with
clipboard.clear
clipboard.settext "Send data to WORD through the clipboard?"
objword.selection.paste
objword.printpreview = true' preview mode
'objWord.PrintOut' to print
'objWord.Quit' to exit word
objerror?
If Err < > 429 Then
MsgBox Str$? Err & Error$
Set objWord = Nothing' exit
exit sub
else
resume next
end if
end sub if you cannot create a Word object.
- Previous article:Who is Brother Momo in Mini World?
- Next article:What are the wonderful excuses for war in history?
- Related articles
- Do you know: What foolish choices did Shaw Brothers make to determine their tragic fate?
- The brain teaser of the kindergarten class has the answer.
- Tang priest's westward journey joke
- What are the top ten advanced technologies in the world?
- Song Dandan no longer hides, uncovers the true face of Ni Ping. Why did they break up?
- Why does the pulse become a sports drink of top 1 in my heart?
- Who do you think you are? What qualifications do you have to make me wait for you for so long?
- I want to know: how to drive from Yangjiang to Shaoguan in Shaoguan?
- Japanese treasure appraisal program found a national treasure worth 25 million. How did the Chinese aunt respond?
- What kind of tea set do tea artists like best to brew green tea?