I am having trouble trying to convert some code to vb.NET. I know that in .NET there is no printer object. The problem I am having is having to do with printers.
There is a component in system.windows.forms called printdocument but I am not sure how to use it in this code. I am trying to set the available printers. Here is the code:
VB Code:
  1. '* Description..: This function sets the current printer from the printer list.      *
  2.     '*                                                                                   *
  3.     '*                Parameter     Description                                          *
  4.     '*                ----------    ---------------------------------------------------  *
  5.     '*                PrtName       Printer name                                         *
  6.     '*************************************************************************************
  7.  
  8.     Sub SetPrinter(ByRef PrtName As String)
  9.        
  10.         'UPGRADE_ISSUE: Printer object was not upgraded. Click for more: 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup2068"'
  11.         Dim x As Printer
  12.        
  13.         On Error GoTo PrinterErr
  14.        
  15.         'UPGRADE_ISSUE: Printers collection was not upgraded. Click for more: 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup2068"'
  16.         For Each x In Printers
  17.             'UPGRADE_ISSUE: Printer property x.DeviceName was not upgraded. Click for more: 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup2069"'
  18.             If x.DeviceName = PrtName Then
  19.                 'UPGRADE_ISSUE: Printer object was not upgraded. Click for more: 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup2068"'
  20.                 Printer = x
  21.                
  22.                 Exit For
  23.             End If
  24.         Next x
  25.        
  26.         Exit Sub
  27.        
  28. PrinterErr:
  29.        
  30.         MsgBox("Printer error has occurred.", MsgBoxStyle.Critical, "Printer Error: " & Err.Number)
  31.        
  32.     End Sub
  33.    
  34.     '*************************************************************************************
  35.     '* Function Name: PrintPos                                                           *                               *
  36.     '* Description..: This function prints text at the current x, y coordinates.         *
  37.     '*                                                                                   *
  38.     '*                Parameter     Description                                          *
  39.     '*                ----------    ---------------------------------------------------  *
  40.     '*                CurX          Current X printer position                           *
  41.     '*                CurY          Current Y printer position                           *
  42.     '*                CurText       Current Text to be printed on the printer            *
  43.     '*************************************************************************************
  44.    
  45.     Sub PrintPos(ByRef CurX As Integer, ByRef CurY As Integer, ByRef CurText As Object)
  46.        
  47.         'UPGRADE_ISSUE: Printer property Printer.CurrentX was not upgraded. Click for more: 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup2069"'
  48.         Printer.CurrentX = CurX
  49.         'UPGRADE_ISSUE: Printer property Printer.CurrentY was not upgraded. Click for more: 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup2069"'
  50.         Printer.CurrentY = CurY
  51.         'UPGRADE_WARNING: Couldn't resolve default property of object CurText. Click for more: 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup1037"'
  52.         'UPGRADE_ISSUE: Printer object was not upgraded. Click for more: 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup2068"'
  53.         'UPGRADE_ISSUE: Printer method Printer.Print was not upgraded. Click for more: 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup2069"'
  54.         Printer.Print(CurText)
  55.        
  56.     End Sub
  57. End Module