IrDA Example Code

Example Code

IrDA Function Reference

The following example shows how to connect to a printer, print some text and then close the printer connection.

Private Function PrinterTest() As Byte
    Dim bPrinterRetry As Boolean

    PrinterTest = 1

    bPrinterRetry = True
    While bPrinterRetry
        ' Connect to the printer
        If (prnConnect(1234567890) = 0) Then
            ' Start printing the text
            If (prnPrintLine("Test print using the SapphireIRDA DLL") <> 0) Then Exit Function
            If (prnNewLine() <> 0) Then Exit Function
            If (prnPrintLine("Purchase online at www.sapphire-solutions.co.uk for commercial version") <> 0) Then Exit Function

            If (prnFormFeed() <> 0) Then Exit Function

            If (prnClosePrinter() <> 0) Then
                MsgBox "Unable to close printer port", vbOKOnly, "SapphireIRDA Print Demo"
            End If

            PrinterTest = 0

            bPrinterRetry = False
        Else
            If MsgBox("Unable to locate printer, plese ensure the IrDA ports are aligned.", vbRetryCancel, "SapphireIRDA Print Demo") = vbCancel Then
                bPrinterRetry = False
                PrinterTest = 2
            End If
        End If
    Wend
End Function