代码如下;
        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) = "QQ"
            .TextMatrix(1, 8) = "手机"
        
        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) = mrc.Fields(3)
            .TextMatrix(.Rows - 1, 4) = mrc.Fields(4)
            .TextMatrix(.Rows - 1, 5) = mrc.Fields(5)
            .TextMatrix(.Rows - 1, 6) = mrc.Fields(6)
            .TextMatrix(.Rows - 1, 7) = mrc.Fields(7)
            .TextMatrix(.Rows - 1, 8) = mrc.Fields(8)
            mrc.MoveNext
        Loop
        
        End With

解决方案 »

  1.   

    .TextMatrix(1, 2) = "性别"   //在此处提示"下表越界"
    ---------------------------------------------------
    因为你没给myFlexGrid设置列数,默认只有两列,而上面这句是给第2行第3列赋值,所以会提示"下标越界"你的数据一共有9列,给myFlexGrid设置9个列就行了:
            With myflexgrid
                .Rows = 2
                .Cols=9   '<----------------------设置9个列
                .CellAlignment = 4
                .TextMatrix(1, 0) = "姓名"
                .TextMatrix(1, 1) = "出生日期"
                .TextMatrix(1, 2) = "性别"   //在此处提示"下表越界"