私はASPプロジェクトを継承しており、ASPの知識がないPHPコーダーです。この投稿が長すぎる場合は申し訳ありませんが、できるだけ多くの情報を提供したいと思います。
私はこの1ブロックのコードで苦労しています。
Dim resultArray As String()
For Each resultitem In resultArray
' Do something with each element of the array
hash.Add(dllFunctionObj.ReturnTemplateField(i), resultitem)
i = i + 1
Next
エラー:
Exception!!: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
解決策は簡単なようです。nullかどうかを確認resultitem
してから、中断するか、次の要素にスキップします。
だから私はこれを試しました:
If IsNull(resultitem) Then
Break
End If
エラー:
BC30451: Name 'IsNull' is not declared.
私はオンラインで見つけた他のいくつかの選択肢を試しました:
IsEmpty(resultitem)
-IsEmptyは宣言されていませんString.IsNullOrEmpty(resultitem)
-インデックスの範囲外エラー、効果がないようですresultitem Is Nothing
-範囲外のインデックスNot (Len(resultitem) > 0)
-範囲外のインデックスLen(resultitem) = 0
-アウトバウンドのインデックス
近づいているように見える唯一のものは:
If Not resultitem Then
Break
End If
エラー:
Exception!!: Conversion from string "some_string_here" to type 'Long' is not valid.
Next
代わりに使用すると、次のBreak
エラーが発生します。
If Not resultitem Then
Next
End If
エラー:
BC30081: 'If' must end with a matching 'End If'.
ヘルプ!
役立つ場合に備えて、コードの完全なブロックを含めます
Dim isResultArray As Boolean
isResultArray = methodInf.ReturnType.IsArray()
If isResultArray Then
Dim resultArray As String()
'*** Invoke the dll function
resultArray = methodInf.Invoke(REMem, args.ToArray)
Dim i As Integer = 0
For Each resultitem In resultArray
If Not resultitem Then
Response.Write("Found null value.")
Exit For
End If
Response.Write("i: " & i & "<br />")
hash.Add(dllFunctionObj.ReturnTemplateField(i), resultitem)
i = i + 1
' i = 6 will cause Get Constituent Name to work
'If i = 6 Then
' Exit For
'End If
Next
outputArray.Add(hash)
Else
'*** could be boolean, string, long etc.
Dim result As String
'*** Invoke the dll function
result = methodInf.Invoke(REMem, args.ToArray)
hash.Add(dllFunctionObj.ReturnTemplateField(0), result)
outputArray.Add(hash)
End If