机房收费系统—查询并导出Excel表

15:30

时间过的很快,但是自己的进度确实有够慢的,很多同学已经开始进入到软工了,自己还为机房收费系统苦恼着。虽然进度很慢,但是每每解决一个问题都很兴奋。

开始都说,只要参考学生信息管理系统敲就行了,但是压根就没有思路,但是现在,只要解决一个,下一个就会有些思路,久而久之,突然感觉有很多相似的窗体,进度要赶,但是自己真正理解了感觉收获更多。

以下是收取金额查询窗体:

Private Sub CmdOK_Click()
    Dim mrc As ADODB.Recordset
    Dim Msgtext As String
    Dim TxtSQL As String
    
    '收取金额查询
        TxtSQL = "select * from ReCharge_Info where date >='" & DTPicker1.Value & "'" & " And date <= '" & DTPicker2.Value & "'"
        Set mrc = ExecuteSQL(TxtSQL, Msgtext)
        
        If Not mrc.EOF = False Then
            MsgBox "无记录!", vbOKOnly + vbExclamation, "警告"
        Else
        
        With MyFlexGrid
        .Rows = 2
        .CellAlignment = 4
        .TextMatrix(1, 0) = "卡号"
        .TextMatrix(1, 1) = "充值金额"
        .TextMatrix(1, 2) = "充值日期"
        .TextMatrix(1, 3) = "充值时间"
        .TextMatrix(1, 4) = "充值教师"
        .TextMatrix(1, 5) = "结账状态"
        
        Do While Not mrc.EOF
            .Rows = .Rows + 1
            .CellAlignment = 4
            .TextMatrix(.Rows - 1, 0) = mrc!cardno
            .TextMatrix(.Rows - 1, 1) = mrc!addmoney
            .TextMatrix(.Rows - 1, 2) = mrc!Date
            .TextMatrix(.Rows - 1, 3) = mrc!Time
            .TextMatrix(.Rows - 1, 4) = mrc!UserID
            .TextMatrix(.Rows - 1, 5) = mrc!Status
            
            mrc.MoveNext
        Loop
        End With
        End If
        mrc.Close
End Sub

导出Excel表:

Private Sub CmdExcel_Click()
    Dim app As Excel.Application
    Dim book As Excel.Workbook
    Dim sheet As Excel.Worksheet
    
    Set app = New Excel.Application
    Set book = app.Workbooks.Add
    Set sheet = book.Worksheets.Add
    
    Dim row As Single
    Dim col As Single
    
    With MyFlexGrid
    
        For row = 0 To .Rows - 1
            For col = 0 To .col - 1
                sheet.Cells(row + 1, col + 1).Value = .TextMatrix(row, col)
                Next col
            Next row
       End With
       
       app.Visible = True
       Exit Sub
End Sub

同样,金额退还信息查询的窗体的代码也就很容易的就可以敲出来了,其他的导出Excel表当然也很容易的完成的。

可能这个窗体的代码很早就完成了,都说很简单,敲完再看确实不难,但是真正自己完成它还是很开心的。



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 16
    评论
评论 16
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值