Can i print line by line in vb.net ...
i am using a dot matrix printer ... is it possible ...
actually i have a class in vb 6.0 that generate a line by line print but don't know how to convert it in .net ...
here is the code in vb 6.0
Code:Option Explicit Private Type DOCINFO pDocName As String pOutputFile As String pDatatype As String End Type Private Declare Function ClosePrinter Lib "winspool.drv" (ByVal _ hPrinter As Long) As Long Private Declare Function EndDocPrinter Lib "winspool.drv" (ByVal _ hPrinter As Long) As Long Private Declare Function EndPagePrinter Lib "winspool.drv" (ByVal _ hPrinter As Long) As Long Private Declare Function OpenPrinter Lib "winspool.drv" Alias _ "OpenPrinterA" (ByVal pPrinterName As String, phPrinter As Long, _ ByVal pDefault As Long) As Long Private Declare Function StartDocPrinter Lib "winspool.drv" Alias _ "StartDocPrinterA" (ByVal hPrinter As Long, ByVal Level As Long, _ pDocInfo As DOCINFO) As Long Private Declare Function StartPagePrinter Lib "winspool.drv" (ByVal _ hPrinter As Long) As Long Private Declare Function WritePrinter Lib "winspool.drv" (ByVal _ hPrinter As Long, pBuf As Any, ByVal cdBuf As Long, _ pcWritten As Long) As Long Dim lhPrinter As Long Public Function NewPage(Optional PrinterName As String, _ Optional DocName As String) As Boolean On Error GoTo NewPage_Error If PrinterName = "" Then PrinterName = Printer.DeviceName If DocName = "" Then DocName = Application.Name Dim lReturn As Long Dim lDoc As Long Dim MyDocInfo As DOCINFO lReturn = OpenPrinter(Printer.DeviceName, lhPrinter, 0) If lReturn = 0 Then MsgBox "No Printer selected!", vbExclamation NewPage = False Exit Function End If MyDocInfo.pDocName = DocName MyDocInfo.pOutputFile = vbNullString MyDocInfo.pDatatype = vbNullString lDoc = StartDocPrinter(lhPrinter, 1, MyDocInfo) Call StartPagePrinter(lhPrinter) NewPage = True On Error GoTo 0 Exit Function NewPage_Error: MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure NewPage of Class Module clsPrintLineByLine" NewPage = False End Function Public Sub PrintLine(ByVal srcToPrint As String) Dim lReturn As Long Dim lpcWritten As Long Dim sWrittenData As String sWrittenData = srcToPrint & vbCrLf lReturn = WritePrinter(lhPrinter, ByVal sWrittenData, _ Len(sWrittenData), lpcWritten) End Sub Public Sub EndPage() Dim lReturn As Long lReturn = EndPagePrinter(lhPrinter) lReturn = EndDocPrinter(lhPrinter) lReturn = ClosePrinter(lhPrinter) End Sub


Reply With Quote
