我一直在努力,为什么下面的代码,通过循环第三次我得到一个错误类型时行“对于lCount = 0至MAXCOUNT”正在13不匹配,找出评估。我原本以为这个问题是从vArray获得价值,但测试显示它是由“For”行触发的。我不知道在循环处理过程中类型将如何改变。谢谢!VB6类型不匹配在循环条件
Public Function FindCodeIndex(vArray As Variant, MatchValue As String) As Integer
''This function locates a value in a combo box returning the index or -1 if not found
Dim lCount As Long
Dim maxCount As Long
Dim arrayStr As String
On Error GoTo ErrorHandler
maxCount = UBound(vArray)
For lCount = 0 To maxCount
arrayStr = vArray(1, lCount)
If UCase$(arrayStr) = UCase$(MatchValue) Then
FindCodeIndex = Int(lCount)
Exit Function
End If
Next lCount
FindCodeIndex = -1
Exit Function
ErrorHandler:
MsgBox "Unexpected error in frmComment::FindCodeIndex()" & vbCrLf & _
"Error Code: " & CStr(Err.Number) & " Error Desc: " & Err.Description
您不会将'arrayStr'赋值给任何值。你确定这不是问题吗? – Dan 2009-11-11 23:09:55
添加了任务(从内存,不在工作PC现在)到arrayStr。测试显示循环在第三遍的For语句失败。 – Timbuck 2009-11-12 01:22:16
蒂姆,你可以用当地人的窗口看到,在第三道次所用的阵列中的数据,并编辑您的问题,包括这个信息。 – 2009-11-14 06:32:28