# Re: Pinter物件如何使用?

Posted by kkcheung on September 10, 1999 at 10:22:13:

In Reply to: Pinter物件如何使用? posted by Lai on September 09, 1999 at 17:06:12:

: 如何以Printer物件将DataGrid上的内容逐笔印出?
: 行与页要如何控制?

下面一段程式,可以将grid的资料经printer物件列印出来但可能有此要作适当的修改,如果有什么问题,可来e-mail再研究.
For row_no = 1 To Grid1.Rows - 1
Grid1.Row = row_no

If row_no = Grid1.Rows - 1 Then '合计前,先空一行
Printer.Print
End If

For col_no = 0 To Grid1.Cols - 1
Grid1.Col = col_no

Select Case col_no

Case 0
Printer.Print Tab(1); Trim(Grid1.Text);

Case 1
Printer.Print Tab(12); Trim(Grid1.Text);

Case 2
Printer.Print Tab(25); Trim(Grid1.Text);

Case 3
Printer.Print Tab(34); Trim(Grid1.Text);

Case 4
Printer.Print Tab(61 - Len(Format(Grid1.Text, "#,###0"))); Format(Grid1.Text, "#,###0");

Case 5
Printer.Print Tab(73 - Len(Format(Grid1.Text, "#,###0.00"))); Format(Grid1.Text, "#,###0.00");

Case 6
Printer.Print Tab(83 - Len(Format(Grid1.Text, "##0.00"))); Format(Grid1.Text, "##0.00");

Case 7
Printer.Print Tab(94 - Len(Format(Grid1.Text, "#,###,##0.00"))); Format(Grid1.Text, "#,###,##0.00");

Case 8
Printer.Print Tab(99); Trim(Grid1.Text)
End Select
Next col_no
Next row_no

Follow Ups: