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:
'* Description..: This function sets the current printer from the printer list. * '* * '* Parameter Description * '* ---------- --------------------------------------------------- * '* PrtName Printer name * '************************************************************************************* Sub SetPrinter(ByRef PrtName As String) 'UPGRADE_ISSUE: Printer object was not upgraded. Click for more: 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup2068"' Dim x As Printer On Error GoTo PrinterErr 'UPGRADE_ISSUE: Printers collection was not upgraded. Click for more: 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup2068"' For Each x In Printers 'UPGRADE_ISSUE: Printer property x.DeviceName was not upgraded. Click for more: 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup2069"' If x.DeviceName = PrtName Then 'UPGRADE_ISSUE: Printer object was not upgraded. Click for more: 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup2068"' Printer = x Exit For End If Next x Exit Sub PrinterErr: MsgBox("Printer error has occurred.", MsgBoxStyle.Critical, "Printer Error: " & Err.Number) End Sub '************************************************************************************* '* Function Name: PrintPos * * '* Description..: This function prints text at the current x, y coordinates. * '* * '* Parameter Description * '* ---------- --------------------------------------------------- * '* CurX Current X printer position * '* CurY Current Y printer position * '* CurText Current Text to be printed on the printer * '************************************************************************************* Sub PrintPos(ByRef CurX As Integer, ByRef CurY As Integer, ByRef CurText As Object) 'UPGRADE_ISSUE: Printer property Printer.CurrentX was not upgraded. Click for more: 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup2069"' Printer.CurrentX = CurX 'UPGRADE_ISSUE: Printer property Printer.CurrentY was not upgraded. Click for more: 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup2069"' Printer.CurrentY = CurY 'UPGRADE_WARNING: Couldn't resolve default property of object CurText. Click for more: 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup1037"' 'UPGRADE_ISSUE: Printer object was not upgraded. Click for more: 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup2068"' 'UPGRADE_ISSUE: Printer method Printer.Print was not upgraded. Click for more: 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup2069"' Printer.Print(CurText) End Sub End Module
