VBA 阵列索引超出范围 求助
请问各位VBA大侠,运行此段代码,当intcount=21时,提示“阵列索引超出范围”,无法再运行下去,如何解决呢?
Public Function LoadFromDB(Connection As sqlDB, SQL As String, _
FieldName As String, Optional NameField As String = "", Optional Append As Boolean = True) As Integer
Dim objRS As Recordset, intCount As Integer
Dim strtemp As String
Set objRS = Connection.OpenRecordset(SQL)
If Not objRS Is Nothing Then
If Not Append Then Clear
intCount = 0
While Not objRS.EOF
AddItem objRS(FieldName), IIf(NameField = "", IsNull(objRS(FieldName)), IsNull(objRS(NameField)))
intCount = intCount + 1
objRS.MoveNext
Wend
Connection.CloseRecordset objRS
LoadFromDB = intCount
Else
LoadFromDB = -1
End If
End Function
[解决办法]
请问,这个问题你到最后解决了吗?我也遇到了同样的问题。。。