下面是我的原代码,执行到几百行时老是出这种错误(一共几千行),每次出现错误的行数还不一样,请高手帮我看看!!Dim v() As String
    Dim i As Long
    v() = Split(RichTextBox2.Text, vbCrLf)
    For i = 0 To UBound(v())If Left(v(i), 3) = "节点号" Then
 strdian = Replace(v(i), " ", "")
 strdian = Replace(strdian, "节点号=", "")
ElseIf Left(v(i), 7) = "设备IP地址1" Then
    strIPAddr = Replace(v(i), " ", "")
    strIPAddr = Replace(strIPAddr, "设备IP地址1=", "")ElseIf Left(v(i), 4) = "节点名称" Then
    strNodeName = Replace(v(i), " ", "")
    strNodeName = Replace(strNodeName, "节点名称=", "")
    ac_Tmp1.Execute " insert into [设备IP对应表](IP,mingcheng,jiedianhao) values('" & strIPAddr & "', '" & strNodeName & "','" & strdian & "')"
End IfNext i
   
  
    ac_Tmp1.Close

解决方案 »

  1.   

    单步调试,下断点.
    确定SQL语句正确.
    确定数组下标未超出.
    确定引用对象有初始化.
      

  2.   

    语法错误
        v() = Split(RichTextBox2.Text, vbCrLf) 
        For i = 0 To UBound(v()) 改为
        v = Split(RichTextBox2.Text, vbCrLf) 
        For i = 0 To UBound(v) 其它的类似
      

  3.   

    Dim v() As String Dim i As Long 
    v = Split(RichTextBox2.Text, vbCrLf) For i = 0 To UBound(v)
    If Left(v(i), 3) = "节点号" Then 
        strdian = Replace(v(i), " ", "") 
        strdian = Replace(strdian, "节点号=", "") 
    ElseIf Left(v(i), 7) = "设备IP地址1" Then 
        strIPAddr = Replace(v(i), " ", "") 
        strIPAddr = Replace(strIPAddr, "设备IP地址1=", "") 
    ElseIf Left(v(i), 4) = "节点名称" Then 
        strNodeName = Replace(v(i), " ", "") 
        strNodeName = Replace(strNodeName, "节点名称=", "") 
    End If 
    Next iac_Tmp1.Execute " insert into [设备IP对应表](IP,mingcheng,jiedianhao) values('" & strIPAddr & "', '" & strNodeName & "','" & strdian & "')" 
      
    ac_Tmp1.Close 
      

  4.   

    你得加个Redim数组重宣告Dim S
    S = Split(RichTextBox2.Text, vbCrLf) 
    Redim Preserve v(UBound(S)) As StringFor i = 0 To UBound(S) 
       v(i)是你的每一个数组的内容
    Next i
      

  5.   

    更正一下
    For i = 0 To UBound(S) 
       v(i)=s(i)
       v(i)是你的每一个数组的内容  或你直接用 s(i)
    Next i 
      

  6.   

    拼一下SQL语句,看看是什么就知道错误所在了
    dim str1 as string
    ……
    str1=" insert into [设备IP对应表](IP,mingcheng,jiedianhao) values('" & strIPAddr & "', '" & strNodeName & "','" & strdian & "')" 
    debug.print str1