• <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>
    • 軟件測試技術
    • 軟件測試博客
    • 軟件測試視頻
    • 開源軟件測試技術
    • 軟件測試論壇
    • 軟件測試沙龍
    • 軟件測試資料下載
    • 軟件測試雜志
    • 軟件測試人才招聘
      暫時沒有公告

    字號: | 推薦給好友 上一篇 | 下一篇

    用VB 5.0從Recordset中打印列表

    發布: 2007-7-14 20:28 | 作者: 佚名    | 來源: 網絡轉載     | 查看: 8次 | 進入軟件測試論壇討論

    領測軟件測試網    Visual Basic 所 附 帶 的 報 表 生 成 器-Crystal Reports, 功 能 強 大, 能 完 成 大 部 分 報 表 的 制 作。 但 在 某 些 情 況 下, 用Crystal Reports 卻 很 難 作 出 報 表 來。 例 如, 根 據 用 戶 輸 入 不 同 的 過 濾(Filter) 條 件, 將 產 生 不 同 的 虛 擬 表, 此 時 用Crystal Reports 制 作 報 表 就 勉 為 其 難 了, 在 這 種 情 況 下, 可 使 用VB 提 供 的Printer 對 象 來 予 以 解 決。

    ---- 下 面 是 本 人 在 給 單 位 開 發 一 個 產 品 銷 售 情 況 統 計 分 析 軟 件 的 過 程 中, 使 用Printer 對 象 從Recordset 對 象 的 虛 擬 表 中 打 印 數 據 的 通 用 代 碼:

    Sub PrintRecordset(recRecordset as Recordset)
    Dim LeftMargin As Integer
    Dim HeadTopPosition As Integer
    Dim FieldNum As Integer
    Dim PageCounter As Integer
    Dim MyRecordset As Recordset
    Const FooterTopPosition=24

    Set MyRecordset=recRecordset
    PageCounter = 1
    ' 設 置Printer 對 象 坐 標 的 度 量 單 位 為 厘 米
    Printer.ScaleMode = vbCentimeters

    LeftMargin = 1.5
    HeadTopPosition = 2

    ---- ' 定 義 打 印 頁 左 上 角 的X 坐 標 和Y 坐 標, 通 過 改 變ScaleLeft 和ScaleTop 的 值, 可 改 變 打 印 頁 的 左 邊 距 和 上 邊 距

    Printer.ScaleLeft = -LeftMargin
    Printer.ScaleTop = -HeadTopPosition

    Printer.Font.Name = "Times New Roman"
    Printer.Font.Size = 12

    Printer.Print "Lovesoft Corp."
    Printer.Print ""

    If MyRecordset.EOF And MyRecordset.BOF Then
    MsgBox "No Record At Presend!",
    vbCritical + vbOKOnly, "Print Error"
    Exit Sub
    End If
    MyRecordset.MoveFirst

    Do Until Printer.CurrentY > FooterTopPosition

    'Print the fields of the recordset in sequence
    For FieldNum = 0 To MyRecordset.Fields.Count - 1
    Printer.Print MyRecordset.Fields
    (FieldNum).Name & _
    ": " & _
    MyRecordset.Fields(FieldNum).Value
    If Printer.CurrentY > FooterTopPosition Then
    Printer.CurrentX = 8
    Printer.Print "Page: " & PageCounter
    ' 創 建 多 頁 文 檔
    Printer.NewPage
    PageCounter = PageCounter + 1
    End If
    Next FieldNum

    MyRecordset.MoveNext
    If MyRecordset.EOF Then Exit Do
    ' 在 記 錄 之 間 空 一 行
    Printer.Print ""
    Loop

    'Print the Page number as a footer
    Printer.CurrentX = 8
    Printer.CurrentY = FooterTopPosition
    Printer.Print "Page: " & PageCounter
    ' 將 輸 出 送 到 打 印 機
    Printer.EndDoc
    End Sub

    ---- 調 用 上 述PrintRecordset 通 用 過 程 相 當 方 便, 下 面 是 通 過cmdPrint 按 鈕 的Click 事 件 進 行 調 用 的 一 個 實 例:

    Private Sub cmdPrint_Click()
    PrintRecordset Data1.Recordset
    End Sub

    延伸閱讀

    文章來源于領測軟件測試網 http://www.kjueaiud.com/


    關于領測軟件測試網 | 領測軟件測試網合作伙伴 | 廣告服務 | 投稿指南 | 聯系我們 | 網站地圖 | 友情鏈接
    版權所有(C) 2003-2010 TestAge(領測軟件測試網)|領測國際科技(北京)有限公司|軟件測試工程師培訓網 All Rights Reserved
    北京市海淀區中關村南大街9號北京理工科技大廈1402室 京ICP備10010545號-5
    技術支持和業務聯系:info@testage.com.cn 電話:010-51297073

    軟件測試 | 領測國際ISTQBISTQB官網TMMiTMMi認證國際軟件測試工程師認證領測軟件測試網

    老湿亚洲永久精品ww47香蕉图片_日韩欧美中文字幕北美法律_国产AV永久无码天堂影院_久久婷婷综合色丁香五月

  • <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>