本文介绍了如何在Visual Basic 2008 Express Edition中修复此错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我以vb形式放置打印按钮代码时:
When i put the print button code in my vb form:
Private Sub btnPrint_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPrint.Click
PrintForm1.PrinterSettings.DefaultPageSettings.Landscape = True
PrintForm1.Print()
它给我错误:对象变量或With块变量未设置
对于行:PrintForm1.PrinterSettings.DefaultPageSettings.Landscape = True
it gives me the error: Object variable or With block variable not set
for line :PrintForm1.PrinterSettings.DefaultPageSettings.Landscape = True
推荐答案
If PrintForm1 IsNot Nothing Then
'YOUR CODE
End If
尼什的猜想:
PrintForm1为null.
试试,
Nish''s Guess:
PrintForm1 is null.
Try,
PrintForm1 = New PrintForm1
PrintForm1.PrinterSettings.DefaultPageSettings.Landscape = True
PrintForm1.Print()
如果有帮助,请将其标记为答案
Mark it as answer if it is helpful
这篇关于如何在Visual Basic 2008 Express Edition中修复此错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!