您现在的位置是: 软件 > 开发者网络 > 程序方舟 > 开发专栏 > VB开发 > 正文
·速成电脑精英(包分配)白领高薪一族从这里开始



-Java套接字编程(下)
-MediaStudio Pro 6.5教程
-三款卸载软件最新试用
-基于Visual C++的Winsock API研究

VB6中用DataReport做报表
2002-01-08· ·李文强 ··yesky

上一页  1 2  


  最后用一个实例模板来说明其使用方法。

  连接数据库

With 数据环境.rsCommand名
If .State = adStateOpen Then .Close
.Source = SQL语句
.Open 打开想输出的数据库数据项以便输出
End With
With 报表名
 .DataSource=数据环境
 .DataMember=Command名 这两行也可固定设好而不必每次设置
 设置页表头部分(RpttLabel…为报表控件名)
 .Sections(2).Controls("RptLabelPage").Caption = "共%P页第%p页"
 .Sections(2).Controls("RptLabelDate").Caption = "打印日期:%D"
 .Sections(3).Controls("RptLabel1").Left=…
 …
 设置细节部分(RptShapeX、RptTextBoxX为报表控件名)
 .Sections(3).Controls("RptShape1").Left=…
 .Sections(3).Controls("RptShape1").Top=…
 .Sections(3).Controls("RptShape1").Height=…
 .Sections(3).Controls("RptShape1").Width=…
 .Sections(3).Controls("RptTextBox1").DataMember=Command名
 .Sections(3).Controls("RptTextBox1").DataField=字段1
 .Sections(3).Controls("RptTextBox1").Font.Name=…
 …
 .Sections(3).Controls("RptShapeN").Visible=False
 .Sections(3).Controls("RptTextBoxN").Visible=False
 …
 . Sections(3).Height=计算出的或固定的细节高度
动态调整报表标题(RptLabelTitle为报表标签控件名)
 .Sections(2). Controls("RptLabelTitle").Left=…
 …
 .Sections(2). Controls("RptLabelTitle").Alignment=…
 …
 调整完毕后
 .Show 或 .PrintReport
End With

  这样做的优点是报表设计时简单,调整方便、随意,只需更改一点代码,而不必为了一点点的修改而费神的在设计窗口调整半天。

上一页  1 2  

【责任编辑:方舟】
【发表评论】【关闭窗口】
■ 相关内容
 用VB设计有安全认证服务的Email
 VB中利用OpenGL绘制三维地质构造图
 用Visual Basic设计Windows门禁程序
 VB实现整点报时
 通讯录用VB做
 用VB编写“红绿灯”程序
 用VB编写收发电子邮件程序
 编写网络寻呼机
 Visual Basic 中制作流水灯
感谢 访问天极网,如果您觉得该文章涉及版权问题,请看这里!