简单的问题,请各位看下 (系列二——加分贴)
3列10行的数据,我把第一列列宽缩小到0,不想在那列添加数据,背景不好看
With MSHFlexGrid1
.Cols = 4
.Rows = 11
End With
j = 1
Do Until rs.EOF
For i = 1 To rs.Fields.Count - 1
MSHFlexGrid1.TextMatrix(j, i) = rs.Fields(i- 1).Value
Next i
rs.MoveNext
j = j + 1
Loop
错误语句:
MSHFlexGrid1.TextMatrix(j, i) = rs.Fields(i - 1).Value
出现问题:超出范围
只要正解者就给100,不够另外开贴发分!!
[解决办法]
顶下
[解决办法]
With MSHFlexGrid1
.Cols = 4
.Rows = 11
End With
定义了4列11行,你的数据集rs中的列或行应该有超出范围才对
试着把cols及rows的值改大些
[解决办法]
With MSHFlexGrid1
.Cols = 4
.Rows = rs.recordcounts+1
End With
j = 1
Do Until rs.EOF
For i = 1 To rs.Fields.Count - 1
MSHFlexGrid1.TextMatrix(j, i) = rs.Fields(i- 1).Value
Next i
rs.MoveNext
j = j + 1
Loop
[解决办法]
With MSHFlexGrid1
j = 1
.Cols = 4
.Rows = rs.recordcounts+1
Do Until rs.EOF
For i = 1 To rs.Fields.Count - 1
TextMatrix(j, i) = rs.Fields(i- 1).Value
Next i
rs.MoveNext
j = j + 1
Loop
End With
[解决办法]
rs.movefirst
for j=1 to 10 '10行
for i=1 to 3 '3列
if not rs.eof then
MSHFlexGrid1.TextMatrix(j, i) = rs.Fields(i- 1).Value
end if
next i
if not rs.eof then
rs.movenext
else
exit for
end if
next j