| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1611 人关注过本帖
标题:求助-下标越界
取消只看楼主 加入收藏
感情拓荒者
Rank: 1
等 级:新手上路
帖 子:28
专家分:0
注 册:2007-12-21
收藏
 问题点数:0 回复次数:6 
求助-下标越界
Private Sub cmdExit_Click()
    Unload Me
End Sub

Private Sub cmdInquire_Click()
    Dim txtSQL As String
    Dim MsgText As String
    Dim dd(4) As Boolean
    Dim mrc As ADODB.Recordset
   
      
    txtSQL = "select * from student_Info where "
    If Check1(0).Value Then
        If Trim(txtSID.Text) = "" Then
            sMeg = "学号不能为空"
            MsgBox sMeg, vbOKOnly + vbExclamation, "警告"
            txtSID.SetFocus
            Exit Sub
        Else
            If Not IsNumeric(Trim(txtSID.Text)) Then
                MsgBox "请输入数字!", vbOKOnly + vbExclamation, "警告"
                Exit Sub
                txtSID.SetFocus
            End If
            dd(0) = True
            txtSQL = txtSQL & "student_ID = '" & Trim(txtSID.Text) & "'"
        End If
    End If
   
    If Check1(1).Value Then
        If Trim(txtName.Text) = "" Then
            sMeg = "姓名不能为空"
            MsgBox sMeg, vbOKOnly + vbExclamation, "警告"
            txtName.SetFocus
            Exit Sub
        Else
            dd(1) = True
            If dd(0) Then
                txtSQL = txtSQL & "and student_Name = '" & txtName.Text & "'"
            Else
                txtSQL = txtSQL & "student_Name = '" & txtName.Text & "'"
            End If
        End If
    End If
   
    If Check1(2).Value Then
        If Trim(txtClassno.Text) = "" Then
            sMeg = "班号不能为空"
            MsgBox sMeg, vbOKOnly + vbExclamation, "警告"
            txtClassno.SetFocus
            Exit Sub
        Else
            dd(2) = True
            If dd(0) Or dd(1) Then
                txtSQL = txtSQL & "and class_No = '" & txtClassno.Text & "'"
            Else
                txtSQL = txtSQL & "class_No = '" & txtClassno.Text & "'"
            End If
        End If
    End If
   
    If Not (dd(0) Or dd(1) Or dd(2) Or dd(3)) Then
        MsgBox "请设置查询方式!", vbOKOnly + vbExclamation, "警告"
        Exit Sub
    End If
   
    txtSQL = txtSQL & " order by student_ID "
    Set mrc = ExecuteSQL(txtSQL, MsgText)
   
    With myflexgrid
        .Rows = 2
        .CellAlignment = 4
        .TextMatrix(1, 0) = "学号"
        .TextMatrix(1, 1) = "姓名"
        .TextMatrix(1, 2) = "性别"
        .TextMatrix(1, 3) = "出生日期"
        .TextMatrix(1, 4) = "班号"
        .TextMatrix(1, 5) = "联系电话"
        .TextMatrix(1, 6) = "入校日期"
        .TextMatrix(1, 7) = "家庭住址"
        
        Do While Not mrc.EOF
            .Rows = .Rows + 1
            .CellAlignment = 4
            .TextMatrix(.Rows - 1, 0) = mrc.Fields(0)
            .TextMatrix(.Rows - 1, 1) = mrc.Fields(1)
            .TextMatrix(.Rows - 1, 2) = mrc.Fields(2)
            .TextMatrix(.Rows - 1, 3) = Format(mrc.Fields(3), "yyyy-mm-dd")
            .TextMatrix(.Rows - 1, 4) = mrc.Fields(4)
            .TextMatrix(.Rows - 1, 5) = mrc.Fields(5)
            .TextMatrix(.Rows - 1, 6) = Format(mrc.Fields(6), "yyyy-mm-dd")
            .TextMatrix(.Rows - 1, 7) = mrc.Fields(7)
            mrc.MoveNext
        Loop
        
    End With
   
    mrc.Close
   
   
End Sub

Private Sub Form_Load()
    With myflexgrid
        .CellAlignment = 4
        .TextMatrix(1, 0) = "学号"
        .TextMatrix(1, 1) = "姓名"
        .TextMatrix(1, 2) = "性别"
        .TextMatrix(1, 3) = "出生日期"
        .TextMatrix(1, 4) = "班号"
        .TextMatrix(1, 5) = "联系电话"
        .TextMatrix(1, 6) = "入校日期"
        .TextMatrix(1, 7) = "家庭住址"
    End With
End Sub

Private Sub myflexgrid_Click()

End Sub
搜索更多相关主题的帖子: Sub Dim 越界 String 
2007-12-26 15:14
感情拓荒者
Rank: 1
等 级:新手上路
帖 子:28
专家分:0
注 册:2007-12-21
收藏
得分:0 
.TextMatrix(1, 6) = "入校日期"
2007-12-26 15:19
感情拓荒者
Rank: 1
等 级:新手上路
帖 子:28
专家分:0
注 册:2007-12-21
收藏
得分:0 
2007-12-26 15:30
感情拓荒者
Rank: 1
等 级:新手上路
帖 子:28
专家分:0
注 册:2007-12-21
收藏
得分:0 
那怎样改啊?
2007-12-26 15:47
感情拓荒者
Rank: 1
等 级:新手上路
帖 子:28
专家分:0
注 册:2007-12-21
收藏
得分:0 
帮帮忙啊!
2007-12-26 16:17
感情拓荒者
Rank: 1
等 级:新手上路
帖 子:28
专家分:0
注 册:2007-12-21
收藏
得分:0 
是啊!
2007-12-26 16:33
感情拓荒者
Rank: 1
等 级:新手上路
帖 子:28
专家分:0
注 册:2007-12-21
收藏
得分:0 
行啦。谢谢啦
2007-12-26 17:02
快速回复:求助-下标越界
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.017868 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved