Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. PrintQueue error

PrintQueue error

Scheduled Pinned Locked Moved Visual Basic
csharphelp
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • O Offline
    O Offline
    Otekpo Emmanuel
    wrote on last edited by
    #1

    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!

    Richard DeemingR 1 Reply Last reply
    0
    • O Otekpo Emmanuel

      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!

      Richard DeemingR Offline
      Richard DeemingR Offline
      Richard Deeming
      wrote on last edited by
      #2

      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

      "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

      O 1 Reply Last reply
      0
      • Richard DeemingR Richard Deeming

        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

        O Offline
        O Offline
        Otekpo Emmanuel
        wrote on last edited by
        #3

        Thanks for your quick response. But how can check if the thPQueue is been initialized or not?

        Richard DeemingR 1 Reply Last reply
        0
        • O Otekpo Emmanuel

          Thanks for your quick response. But how can check if the thPQueue is been initialized or not?

          Richard DeemingR Offline
          Richard DeemingR Offline
          Richard Deeming
          wrote on last edited by
          #4

          If it's Nothing, then it hasn't been initialized. Debug your code and step through the part that creates the PrintQueue. 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

          "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups