Code Examples

Studying, building, and modifying code examples is the perfect way to learn to use the List & Label report generator in a hands-on way. Below are several examples for major programming languages. Download your free trial version of List & Label for even more ready-to-use code examples.

Starting the Designer

'Start the Designer with the title "Invoice" and the file "invoice.rpt":
ListLabel1.Design(0, hWnd, "Invoice", LL_PROJECT_LIST, "invoice.rpt", 1)

End Sub
For data definition the event ListLabel1_CmndDefineFields is used.

Printing

Private Sub ButtonPrint_Click()
'Print the project "test.lst" on the printer
Data1.Recordset.MoveFirst
ListLabel1.Print(0, LL_PROJECT_LIST, "test.lst",_
True, LL_PRINT_NORMAL, LL_BOXTYPE_NORMALWAIT, hWnd,_
"Print, True, Environ$("temp"))
End SubPrivate Sub ListLabel1_CmndDefineFields(ByVal nUserData As Long,
ByVal bDummy As Long, nProgressInPerc As Long, pbLastRec As Long)
'This event is called by the commands Print and Design
'It is called for each record to declare the fields and
'their contents to List & Label
'Repeat for all fields of a 'record
For i = 0 To Form1.Data1.Recordset.Fields.Count - 1
content$ = Data1.Recordset.Fields(i)
nRet = ListLabel1.LlDefineFieldExt _
(Data1.Recordset.Fields(i).Name, content$, LL_TEXT)
Next i
'Skip to next record:
Form1.Data1.Recordset.MoveNext
'Stop printing if last record is reached:
If Form1.Data1.Recordset.EOF = True Then
pbLastRec = 1
End If
End Sub