我在VB6中使用msflexgrid。如何删除或解决以下错误:
下标超出范围。
With flxData(0)
For i = 1 To .Rows - 1
Do While cboselect <> .TextMatrix(i, 1)
.RemoveItem (i)
Loop
Next i
End with
答案 0 :(得分:1)
刚刚意识到Do While
循环内部的For
循环会导致错误显示 - 一旦某行没有所需的cboselect
值,就会#39 ;为了那个和所有剩余的行,打算调用RemoveItem
,直到它们全部被删除,然后它在尝试删除(现在)不存在时显示该消息行。
我猜你想要删除与cboselect
值不匹配的行,这样就会调用If
语句。您还需要向后运行For
循环。试试这个:
With flxData(0)
For i = .Rows - 1 to 1 Step -1
If cboselect <> .TextMatrix(i, 1) Then
.RemoveItem (i)
End If
Next i
End With