Hi,
what is wrong with this code:
temp() = conv.WGS84UTMTOLatLon(32,temp(1),True,temp(0))
Nothing as that is not where the problem lies! Lines like those below are causing the problem by confusing the optimising compiler, and because the line number where the error occurs is not reported by an optimised compiled app you think that when you comment out a line and the error disappears it is that line that is at fault. This is not necessarily so.
Dim temp(0) 'As Double
....
temp() = StrSplit(data,",")
Initially you have declared temp() as Double and the optimising compiler has remembered this and will treat any references to elements of the array as Doubles. Later the optimising compiler has seen the allocation of StrSplit to temp() and notes that the array has now changed to a String array as that is what StrSplit returns. Any use of the elements of the temp() array it now treats as Strings. Unfortunately the order in which the optimising compiler notes the various whole array assignments to temp() is not necessarily same order in which they occur at runtime, so at runtime where the compiler compiled with an expectation of Strings or Doubles the array actually contains Doubles or Strings instead
The solution is not to use strongly typed arrays for anything other than holding the return from a library (the most likely use). Use other untyped arrays for general purpose uses.
I have run into this problem several times now and I have had a couple of private email exchanges with Erel about it. I think that once an array is declared as typed it should not be allowed to change type. This would stop people like yourself running into these apparently inexplicable problems in the future.