大雀软件园

首页 软件下载 安卓市场 苹果市场 电脑游戏 安卓游戏 文章资讯 驱动下载
技术开发 网页设计 图形图象 数据库 网络媒体 网络安全 站长CLUB 操作系统 媒体动画 安卓相关
当前位置: 首页 -> 技术开发 -> Script -> vsprint打印实例

vsprint打印实例

时间: 2021-07-31 作者:daque

 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 ifend 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                .tablecell(tccolspan, 1, 4) = 10                .tablecell(tcrowspan, 1, 1) = 2                .tablecell(tcrowspan, 1, 2) = 2                .tablecell(tcrowspan, 1, 3) = 2                '///                .tablecell(tctext, 1, 1) = "序号"                .tablecell(tctext, 1, 2) = "工程单价称呼"                .tablecell(tctext, 1, 3) = "单价"                .tablecell(tctext, 1, 4) = "个中"                .tablecell(tctext, 2, 4) = "人为费"                .tablecell(tctext, 2, 5) = "资料费"                .tablecell(tctext, 2, 6) = "板滞费"                .tablecell(tctext, 2, 7) = "其余径直费"                .tablecell(tctext, 2, 8) = "当场经费"                .tablecell(tctext, 2, 9) = "径直工程费"                .tablecell(tctext, 2, 10) = "转弯抹角费"                .tablecell(tctext, 2, 11) = "安置成本"                .tablecell(tctext, 2, 12) = "税金"                .tablecell(tctext, 2, 13) = "材差"                '///                .tablecell(tcalign, 1, 1, 1, 13) = tacentermiddle '题目行居中对齐                .tablecell(tcalign, 2, 4, 2, 13) = tacentermiddle '题目行居中对齐                                .tablecell(tcalign, 3, 1, trows, 1) = tacentermiddle '第一列居中对齐                .tablecell(tcalign, 3, 2, trows, 2) = taleftmiddle '第二列居中左对齐                .tablecell(tcalign, 3, 3, trows, 13) = tarightmiddle '其余列居中右对齐'*************************************向每一页面增添数据*************************************                icurrent = 0                do while not rst.eof                    irow = irow + 1                    '当暂时页面数据增添完畏缩出轮回,发端下一页面                    if icurrent <> 0 and icurrent mod 18 = 0 then                        exit do                    end if                    .tablecell(tctext, 3 + icurrent, 1) = rst.fields("nn") & ""                    .tablecell(tctext, 3 + icurrent, 2) = rst.fields("name") & ""                    .tablecell(tctext, 3 + icurrent, 3) = formatdata2(val(rst.fields("price1") & ""), val(rst.fields("unit") & ""))                    .tablecell(tctext, 3 + icurrent, 4) = formatdata2(val(rst.fields("pricerengong") & ""), val(rst.fields("unit") & ""))                    .tablecell(tctext, 3 + icurrent, 5) = formatdata2(val(rst.fields("pricecailiao") & ""), val(rst.fields("unit") & ""))                    .tablecell(tctext, 3 + icurrent, 6) = formatdata2(val(rst.fields("pricejixie") & ""), val(rst.fields("unit") & ""))                    .tablecell(tctext, 3 + icurrent, 7) = formatdata2(val(rst.fields("priceqitazhijie") & ""), val(rst.fields("unit") & ""))                    .tablecell(tctext, 3 + icurrent, 8) = formatdata2(val(rst.fields("pricexianchang") & ""), val(rst.fields("unit") & ""))                    .tablecell(tctext, 3 + icurrent, 9) = formatdata2(val(rst.fields("pricezhijiegongcheng") & ""), val(rst.fields("unit") & ""))                    .tablecell(tctext, 3 + icurrent, 10) = formatdata2(val(rst.fields("pricejianjie") & ""), val(rst.fields("unit") & ""))                    .tablecell(tctext, 3 + icurrent, 11) = formatdata2(val(rst.fields("pricejihualirun") & ""), val(rst.fields("unit") & ""))                    .tablecell(tctext, 3 + icurrent, 12) = formatdata2(val(rst.fields("priceshuijin") & ""), val(rst.fields("unit") & ""))                    .tablecell(tctext, 3 + icurrent, 13) = formatdata2(val(rst.fields("priceshashijiacha") & ""), val(rst.fields("unit") & ""))                    rst.movenext                    icurrent = icurrent + 1                loop                .endtable                '确定暂时记载的场所能否为结果一条,即使不是结果一条,发端新的一页                if irow < rows then                    .newpage '发端新的一页                end if            next ipage'*************************************中断打字与印刷文书档案*************************************            .enddoc        end with    else        msgbox "没有要打字与印刷的数据", vbokonly + vbinformation    end if    rst.close    con.close    set rst = nothing    set con = nothing    exit suberr1:    msgbox err.description, vbokonly + vbinformation, "提醒"end sub

热门阅览

最新排行

Copyright © 2019-2021 大雀软件园(www.daque.cn) All Rights Reserved.