用DATA控件显示,然后逐条记录打印。
PRINTER.PRINT DATA1.RECORDSET!字段名
PRINTER.PRINT DATA1.RECORDSET!字段名
解决方案 »
- 请问以下这段代码中红色标注部分有什么作用呢?
- 请问如何写软件试用代码
- save as problem. 请教高手
- 怎样获得鼠标在屏幕上的坐标?
- 谁能提供一个用webbrowser控制页面字体大小的列子,或告诉我有什么方法。
- 1000分,只求一种方法!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- 用VB怎么实现我的邮箱里收到了新邮件?
- 求救:函数调用出错。得不出结果了
- ◇◆◇ 暑假完了,要上学了,灌水也停止了,送点分,介绍几个好的站点,做点善事,愿主保佑你们! ◇◆◇
- 200分问题:输入汉字如何反查拼音?
- windows ce 相关
- 用CommonDialog控件打开选择字体窗口时,将Flags 设置成 cdlCFEffects Or cdlCFBoth后,运行后想隐藏颜色选择怎么办?
例子:简单的预览和打印功能:
你在Form中间加一个PictureBox,设Appearance=0,大小比例与一张打印纸相似。
再加两个按钮:“预览“(Preview)和“打印“(Print)按钮。Sub SetData(obj As Object)
If TypeOf obj Is Picture Then
obj.Cls
End If
On Error GoTo exit_data
Dim CX, CY, i, curY, curX
Dim StepRow, lColor, adjRowHeight, iBottomRight
lColor = obj.ForeColor
'首行显示公司名称
CX = 4
obj.Font.Bold = False
obj.Font.Size = 9
obj.CurrentY = CX
obj.CurrentX = obj.Width / 2 - obj.TextWidth("地球")
'obj.ForeColor = RGB(256, 0, 0)
obj.Print "地球公司"
StepRow = obj.TextHeight("A")
'标题
CX = CX + StepRow
obj.Font.Bold = True
obj.Font.Size = 2 * 9
obj.CurrentY = CX
obj.CurrentX = obj.Width / 2 - obj.TextWidth("存款")
obj.ForeColor = RGB(256, 0, 0) '红色
obj.Print "存款单据"
StepRow = obj.TextHeight("A")
'首部信息第一行
obj.ForeColor = lColor '恢复
CX = CX + StepRow
obj.Font.Bold = False
obj.Font.Size = 9
obj.CurrentY = CX: obj.CurrentX = 150
obj.Print "左"
obj.CurrentY = CX: obj.CurrentX = obj.Width / 2 - obj.TextWidth("中") / 2
obj.Print "中"
obj.CurrentY = CX: obj.CurrentX = obj.ScaleWidth - 150 - obj.TextWidth("右")
obj.Print "右"
'=================画行线=================
curY = CX + StepRow: curX = 150
For i = 1 To 5
If i = 1 Then
obj.DrawWidth = 2
Else
obj.DrawWidth = 1
End If
obj.Line (curX, curY)-(obj.ScaleWidth - 150, curY)
iBottomRight = curY
'~~~~~
adjRowHeight = obj.TextHeight("A") + 3
curY = curY + adjRowHeight + 4
Next
'=============画竖线=================
curY = CX + StepRow: curX = 150
For i = 1 To 2
obj.DrawWidth = 1
obj.Line (curX, curY)-(curX, iBottomRight)
curX = curX + obj.Width / 2 - obj.TextWidth("中") / 2
Next
obj.Line (obj.ScaleWidth - 150, curY)-(obj.ScaleWidth - 150, iBottomRight)
'==============打印数据==================
Dim str
str = "打印数据"
curY = CX + StepRow + ((adjRowHeight + 4) / 2) - obj.TextHeight("A") / 2
curX = (150 + obj.Width / 2) / 2 - obj.TextWidth(str) / 2
obj.CurrentY = curY
obj.CurrentX = curX
obj.Print str
'...
Exit Sub
exit_data:
MsgBox Error
Exit Sub
End SubPrivate Sub Preview_Click()
SetData Pic
End SubPrivate Sub Print_Click()
SetData Printer
Printer.EndDoc
End Sub
你可以按以上方法将Grid的内容打印出来。效果不错的。
2.保存为文件(格式化)
3.RICHedit.loadfile
4.richedit.edit
2.保存为文件(格式化)
3.RICHedit.loadfile
4.richedit.print
有没有更简单一点的可以把msflexgrid所有记录打印出来的方法?
3。直接操作open将prn设备打开,输出打印,也很容易
4。水晶报表
Help中有例子。
效果很好。
private mlngleftmargin as long
private mlngheaderfontsize as long
private mlngbodyfontsize as long
private mstrheaderfontname as long
private mstrbodyfontname as long
private db as database
private rs as recordset
private sub form_load()
printer.scalemode=vbpoints
mlngtopmargin=72
mlngleftmargin=72
mlngheaderfontsize=18
mlngbodyfontsize=12
mstrheaderfontname="Arial"
mstrbodyfontname="Times New Roman"
set db=opendatabase(app.path & \你的数据库)
end subprivate sub printheader() printer.currentX=mlngleftmargin
printer.currentY=mlbgtopmargin
with printer.font
.name=mstrheaderfontname
.size=mlbgheaderfontsize
.bold=true
end withprinter.print "employee report"
printer.line(mlngleftmargin,mlngropmargin+24)-(printer.scalewidth-72,mlngtopmargin+24)end sub
private sub printdata()
set rs=db.openrecordset("tblemployee")
with printer.font
.name=mstrbodyfontname
.size=mlngbodyfontsize
.body=false
end with
do until rs.EOF
printer.currentX=mlngleftmargin
printer.print rs!firstname & " " & rs! lastname;
printer.currentX=mlngleftmargin+144
printer.print format(rs!salestodate,"$0.00")
rs.movenext
loop
end sub
private sub cmdprint_click()printerheader
printer.currentY=printer.currentY+24
printdata
printer.enddoc
end sub你可以修改这个代码以支持多页打印。监视printer对象的currentY属性的状态就可以作到这一点,当currenty的值接近1英寸或如scaleheight属性所付给的值时,实行printer对象的newpage方法,并再次执行printheader子程序,然后接着输出。
如在vb中可用Data控件.
那么用Access本身的查询打印不就行了吗.