转至繁体中文版     | 网站首页 | 图文教程 | 资源下载 | 站长博客 | 图片素材 | 武汉seo | 武汉网站优化 | 
最新公告:     敏韬网|教学资源学习资料永久免费分享站!  [mintao  2008年9月2日]        
您现在的位置: 学习笔记 >> 图文教程 >> 软件开发 >> VB.NET程序 >> 正文
vsprint打印实例         ★★★★

vsprint打印实例

作者:闵涛 文章来源:闵涛的学习笔记 点击数:1381 更新时间:2009/4/23 16:37:43

Option Explicit

Public Function formatData2(ByVal data1 As Double, ByVal data2 As Double) As String
    Dim dt1, dt2 As Double
    dt1 = data1
    dt2 = data2
    If dt1 = 0 Or dt1 = 0# Or dt2 = 0 Or dt2 = 0# Then
        formatData2 = "0.00"
    Else
        formatData2 = Format(Round(dt1 / dt2, 2), "0.00")
    End If
End Function

Public Sub print_jian_anhuizong(ByRef printCtl As VSPrinter, ByVal strTable As String, ByVal strTitle)
    Dim con As New ADODB.Connection
    Dim rst As New ADODB.Recordset
    Dim str_table As String
    Dim str_title As String
    Dim strSql As String
    Dim iCurrent As Integer
    Dim cols As Integer ''''页面表格的列数
    Dim iCurrenrows As Integer ''''页面表格当前显示的总行数
    Dim Rows As Long ''''总行数
    Dim Trows As Long ''''页面表格总行数
    Dim pages As Integer ''''总页数
    Dim iPage As Integer ''''当前页面
    Dim iLastrows As Integer ''''整页显示后剩余的行数
    Dim iRow As Long ''''当前行的位置
On Error GoTo err1
    str_table = strTable
    str_title = strTitle
    con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strConnection & ";Persist Security Info=False"
    con.Open
    strSql = "select nn,name,unit,pricezhijiegongcheng,pricezhijie,pricerengong,pricecailiao,pricejixie," & _
            "priceqitazhijie,pricexianchang,pricejianjie,pricejihualirun,priceshuijin,priceshashijiacha ,price1 from " & str_table & " order by nn"
    rst.CursorType = adOpenKeyset
    rst.LockType = adLockOptimistic
    rst.Open strSql, con, , , adCmdText
    cols = 13
    If Not rst.BOF And Not rst.EOF Then
        ''''获得总的记录数rows
        rst.MoveFirst
        Do While Not rst.EOF
            Rows = Rows + 1
            rst.MoveNext
        Loop
        ''''重新设置行的位置为第一条记录
        rst.MoveFirst
        ''''设置总的页面数
        If Rows <= 18 Then ''''总行数小于等于页面显示的总行数
            pages = 1
            iCurrenrows = Rows
            iLastrows = 0
        Else ''''总行数大于页面显示的总行数
            If Rows Mod 18 = 0 Then ''''总行数等于页面显示的总行数倍数
                pages = Int(Rows / 18)
                iLastrows = 0
            Else ''''总行数不等于页面显示的总行数倍数
                pages = Int(Rows / 18) + 1
                iLastrows = Rows Mod 18
            End If
            iCurrenrows = 18
        End If
        iPage = 1 ''''设置当前页面为第一页面
        iRow = 0 ''''设置当前行位置为空
        ''''
        With printCtl
            .Orientation = orLandscape ''''设置横向打印
            .TableBorder = tbAll
            ''''设置页面四边的边距
            .MarginTop = 1400
            .MarginBottom = 1400
            .MarginLeft = 1400
            .MarginRight = 1400
            ''''设置字体名字
''''*************************************开始打印文档的内容*************************************            .StartDoc
            .StartDoc
            .TablePen = 20
            For iPage = 1 To pages
                 ''''设置标题
                .FontSize = 14
                .FontBold = True
                .TextAlign = taCenterMiddle
                .Paragraph = str_title
                .Paragraph = ""
                .FontBold = False
                .FontSize = 10
                ''''设置页面表格
                .FontSize = 9
                .StartTable
                .TextAlign = taRightMiddle
                .Paragraph = "单位: 元"
                .StartTable
                .TableCell(tcCols) = cols
                If iPage = pages And iLastrows <> 0 Then
                    Trows = iLastrows + 2
                Else
                     Trows = iCurrenrows + 2
                End If
                .TableCell(tcRows) = Trows
                ''''///
                .TableCell(tcRowHeight) = 400
                .TableCell(tcColWidth, , 1) = 600
                .TableCell(tcColWidth, , 2) = 2600
                .TableCell(tcColWidth, , 3) = 1000
                .TableCell(tcColWidth, , 4) = 1000
                .TableCell(tcColWidth, , 5) = 1000
                .TableCell(tcColWidth, , 6) = 1000
                .TableCell(tcColWidth, , 7) = 1000
                .TableCell(tcColWidth, , 8) = 1000
                .TableCell(tcColWidth, , 9) = 1000
                .TableCell(tcColWidth, , 10) = 1000
                .TableCell(tcColWidth, , 11) = 1000
                .TableCell(tcColWidth, , 12) = 1000
                .TableCell(tcColWidth, , 13) = 1000
                .Table

[1] [2]  下一页


没有相关教程
教程录入:mintao    责任编辑:mintao 
  • 上一篇教程:

  • 下一篇教程:
  • 【字体: 】【发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口
      注:本站部分文章源于互联网,版权归原作者所有!如有侵权,请原作者与本站联系,本站将立即删除! 本站文章除特别注明外均可转载,但需注明出处! [MinTao学以致用网]
      网友评论:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!)

    同类栏目
    · C语言系列  · VB.NET程序
    · JAVA开发  · Delphi程序
    · 脚本语言
    更多内容
    热门推荐 更多内容
  • 没有教程
  • 赞助链接
    更多内容
    闵涛博文 更多关于武汉SEO的内容
    500 - 内部服务器错误。

    500 - 内部服务器错误。

    您查找的资源存在问题,因而无法显示。

    | 设为首页 |加入收藏 | 联系站长 | 友情链接 | 版权申明 | 广告服务
    MinTao学以致用网

    Copyright @ 2007-2012 敏韬网(敏而好学,文韬武略--MinTao.Net)(学习笔记) Inc All Rights Reserved.
    闵涛 投放广告、内容合作请Q我! E_mail:admin@mintao.net(欢迎提供学习资源)

    站长:MinTao ICP备案号:鄂ICP备11006601号-18

    闵涛站盟:医药大全-武穴网A打造BCD……
    咸宁网络警察报警平台