函数:Row和Rows的用法区别?

前提

刚刚敲代码时,出现了30009的错误,后来找出问题竟然发现只是少了一个S

温习知识

Row:返回单元格或者区域所在的行号;
Rows:返回区域的行数,即高度,有几行。
前者常用于数组公式,用来返回1234…常量,进行枚举运算

出现问题

在这里插入图片描述

解决方法

Private Sub cmdquery_Click()
Dim txtsql, msgtext As String
Dim mrc As ADODB.Recordset

If Not testtxt(Trim(txtcardno.Text)) Then
MsgBox “请输入卡号!”, 0 + 48, “提示”
txtcardno.SetFocus
Exit Sub
End If

 If Not IsNumeric(Trim(txtcardno.Text)) Then
        MsgBox "请输入数字", 0 + 48, "提示"
        txtcardno.Text = ""
        txtcardno.SetFocus
        Exit Sub
    End If
    
    txtsql = "select * from line_info where cardno = '" & Trim(txtcardno.Text) & "'"
    Set mrc = ExecuteSQL(txtsql, msgtext)

    If mrc.EOF = True Then
        MsgBox "卡号不存在,请重新输入", 0 + 48, "提示"
        txtcardno.Text = ""
        txtcardno.SetFocus
        Exit Sub
    End If
    
    With myFlexGrid1
        .Rows = 1  *'把Row改成Rows就行了*
        .CellAlignment = 4
        .TextMatrix(0, 0) = "卡号"
        .TextMatrix(0, 1) = "姓名"
        .TextMatrix(0, 2) = "上机日期"
        .TextMatrix(0, 3) = "上机时间"
        .TextMatrix(0, 4) = "下机日期"
        .TextMatrix(0, 5) = "下机时间"
        .TextMatrix(0, 6) = "消费金额"
        .TextMatrix(0, 7) = "余额"
        .TextMatrix(0, 8) = "备注"
        
    Do While Not mrc.EOF
        .Rows = .Rows + 1
        .CellAlignment = 4
        .TextMatrix(.Rows - 1, 0) = mrc.Fields(1)
        .TextMatrix(.Rows - 1, 1) = mrc.Fields(3)
        .TextMatrix(.Rows - 1, 2) = mrc.Fields(6)
        .TextMatrix(.Rows - 1, 3) = mrc.Fields(7)
        .TextMatrix(.Rows - 1, 4) = mrc.Fields(8) & ""
        .TextMatrix(.Rows - 1, 5) = mrc.Fields(9) & ""
        .TextMatrix(.Rows - 1, 6) = mrc.Fields(11) & ""
        .TextMatrix(.Rows - 1, 7) = mrc.Fields(12) & ""
        .TextMatrix(.Rows - 1, 8) = mrc.Fields(13) & ""

            '移动到下一条记录
            mrc.MoveNext
        Loop
        End With    
        mrc.Close

End Sub
  • 2
    点赞
  • 17
    收藏
    觉得还不错? 一键收藏
  • 4
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值