vb制作报表曾经站位

第一步:下载安装grid++report (下载grid++report)

第二步:创建报表模板。 (如何制作报表模板

第三步:添加应用和部件(部件 :和 引用:)

第四步:用VB将报表连接起来。(报表的位置app.path最方便 )

Dim WithEvents Report As grproLibCtl.GridppReport

Private Sub cmdPre_Click()
    Report.PrintPreview (True)
End Sub

Private Sub cmdPrint_Click()
   '因为报表对象的 Print 方法名与 VB 内部定义有冲突,所以要用中括号括起来
    Report.[Print] (True)
End Sub

Private Sub Command1_Click()
        GrdisplayViewer1.Refresh
End Sub

Private Sub Form_Load()
    '创建报表对象
    Set Report = New grproLibCtl.GridppReport
    '载入报表模板文件
    Report.LoadFromFile ("C:\Users\HaifANG\Desktop\机房收费系统1.0\byDay.grf") '
    strTxtsql = "select * from allbyday_tableInfo where date='" & Format(Now,"yyyy-mm-dd") & "'"
  '设置数据连接串
    Report.DetailGrid.Recordset.ConnectionString = "FILEDSN=computerChargeSys.dsn;UID=sa;PWD=123456"
    Report.DetailGrid.Recordset.Querysql = strTxtsql
    
    GrdisplayViewer1.Report = Report
    GrdisplayViewer1.Start
    
    
End Sub
 
Private Sub Form_Resize()
    GrdisplayViewer1.Left = 0
    GrdisplayViewer1.Width = Me.Width - 500
End Sub

Private Sub Report_Initialize()

    '设置各个参数的值
                          
    Report.ParameterByName("makedate").Asstring = Format$(Date,"yyyy-mm-dd")    '显示开始日期
'    Report.ParameterByName("DateEnd").Asstring = Format$(DTPEnd.Value,"yyyy-mm-dd")        '显示结束日期
'
End Sub

在报表GridReport中显示日期时间的改变: http://www.jb51.cc/article/p-bwkaymyg-ts.html

相关文章

Format[$] ( expr [ , fmt ] ) format 返回变体型 format$ 强...
VB6或者ASP 格式化时间为 MM/dd/yyyy 格式,竟然没有好的办...
在项目中添加如下代码:新建窗口来显示异常信息。 Namespace...
转了这一篇文章,原来一直想用C#做k3的插件开发,vb没有C#用...
Sub 分列() ‘以空格为分隔符,连续空格只算1个。对所选...
  窗体代码 1 Private Sub Text1_OLEDragDrop(Data As Dat...