Public Sub printfile()
On Error GoTo error3
CommonDialog1.DialogTitle = "Please choose print!"
CommonDialog1.ShowPrinter
If CommonDialog1.CancelError Then
GoTo error2
Else
Form1.PrintForm
Printer.EndDoc
End If
GoTo en
error2:
MsgBox "Print fail!"
GoTo en
error3:
MsgBox "Can't find printer"
en: End Sub以上是我寫的打印程序. 不能打印. 請大俠幫幫看看.
On Error GoTo error3
CommonDialog1.DialogTitle = "Please choose print!"
CommonDialog1.ShowPrinter
If CommonDialog1.CancelError Then
GoTo error2
Else
Form1.PrintForm
Printer.EndDoc
End If
GoTo en
error2:
MsgBox "Print fail!"
GoTo en
error3:
MsgBox "Can't find printer"
en: End Sub以上是我寫的打印程序. 不能打印. 請大俠幫幫看看.
Public Sub printfile()
On Error GoTo ErrLine
CommonDialog1.DialogTitle = "Please choose print!"
CommonDialog1.ShowPrinter
Form1.PrintForm
Printer.EndDoc
Exit Sub
ErrLine:
MsgBox Err.Description
End Sub
关键在于MsgBox Err.Description 可以直接把出错的信息显示出来。以便于调试