learning
Active member
Is it good practice to program with option strict on? And, if so, can you tell me how to avoid late binding errors in situations like this?
The portion of the code that gets the late binding error is here and I'm wondering how to avoid it.
VB.NET:
Public Function Subtract(ByVal arr1 As Array, ByVal arr2 As Array) As Array ' arr2 - arr1
Dim ul As Integer
Dim ll As Integer
Dim lpc As Integer
Dim tempArr As Array
ul = arr1.GetUpperBound(0)
ll = arr1.GetLowerBound(0)
If ul = arr2.GetUpperBound(0) And ll = arr2.GetLowerBound(0) Then
tempArr = Array.CreateInstance(GetType(Single), ul + 1)
For lpc = ll To ul
tempArr(lpc) = arr2(lpc) - arr1(lpc)
Next
Return tempArr
Else
tempArr = Array.CreateInstance(GetType(Single), 1)
Return tempArr
MsgBox("Error - Array sizes are different")
End If
End Function
The portion of the code that gets the late binding error is here and I'm wondering how to avoid it.
VB.NET:
For lpc = ll To ul
tempArr(lpc) = arr2(lpc) - arr1(lpc)
Next