我在VB6中使用msflexgrid。如何删除或解决以下错误:
下标超出范围。
With flxData(0)
For i = 1 To .Rows - 1
Do While cboselect <> .TextMatrix(i, 1)
.RemoveItem (i)
Loop
Next i
End with发布于 2016-10-28 15:48:03
刚刚意识到,Do While循环中的For循环将导致显示错误--一旦一行没有所需的cboselect值,它将调用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 Withhttps://stackoverflow.com/questions/40263618
复制相似问题