首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VBA >

VBA 阵列索引超出范围

2012-02-12 
VBA阵列索引超出范围求助请问各位VBA大侠,运行此段代码,当intcount21时,提示“阵列索引超出范围”,无法再运

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


[解决办法]
请问,这个问题你到最后解决了吗?我也遇到了同样的问题。。。

热点排行