PrintQueue error
-
Good day friends, I am trying to check the status of a printer connected to a system from VB.Net application. But when I start the application, it shows the following error: Object reference not set to an instance of an object. pointing to the PrintQueue. I made a successful reference to the System.Print.
Imports System.Printing
Public Class Form1
Private Sub ConnectionStatusToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles ConnectionStatusToolStripMenuItem.Click
If thPQueue.IsOffline = True Then
MsgBox("The printer is currently offline.", vbInformation + vbOKOnly, "Printer Status")
ElseIf thPQueue.IsWaiting Then
MsgBox("The printer is on wait mode.", vbInformation + vbOKOnly, "Printer Status")
ElseIf thPQueue.IsWarmingUp Then
MsgBox("The printer is currently warming up. Please wait", vbInformation + vbOKOnly, "Printer Status")
ElseIf thPQueue.IsNotAvailable Then
MsgBox("The printer is currently not available.", vbInformation + vbOKOnly, "Printer Status")End If End Sub
End Class
Any solution will be appreciated. Thanks in advance!
-
Good day friends, I am trying to check the status of a printer connected to a system from VB.Net application. But when I start the application, it shows the following error: Object reference not set to an instance of an object. pointing to the PrintQueue. I made a successful reference to the System.Print.
Imports System.Printing
Public Class Form1
Private Sub ConnectionStatusToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles ConnectionStatusToolStripMenuItem.Click
If thPQueue.IsOffline = True Then
MsgBox("The printer is currently offline.", vbInformation + vbOKOnly, "Printer Status")
ElseIf thPQueue.IsWaiting Then
MsgBox("The printer is on wait mode.", vbInformation + vbOKOnly, "Printer Status")
ElseIf thPQueue.IsWarmingUp Then
MsgBox("The printer is currently warming up. Please wait", vbInformation + vbOKOnly, "Printer Status")
ElseIf thPQueue.IsNotAvailable Then
MsgBox("The printer is currently not available.", vbInformation + vbOKOnly, "Printer Status")End If End Sub
End Class
Any solution will be appreciated. Thanks in advance!
If thPQueue Is Nothing Then
MsgBox("Printer queue not initialized.", vbCritical + vbOKOnly, "Printer Status")
ElseIf ...Now debug your code and find out why
thPQueue
has not been initialized.
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
-
If thPQueue Is Nothing Then
MsgBox("Printer queue not initialized.", vbCritical + vbOKOnly, "Printer Status")
ElseIf ...Now debug your code and find out why
thPQueue
has not been initialized.
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
Thanks for your quick response. But how can check if the thPQueue is been initialized or not?
-
Thanks for your quick response. But how can check if the thPQueue is been initialized or not?
If it's
Nothing
, then it hasn't been initialized. Debug your code and step through the part that creates thePrintQueue
. Either it's not being executed, or it's not doing what you expect.
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer