Error message: error CS0029: Cannot implicitly convert type 'string[]' to 'long[]'
What is the best way to handle this?
Of course I can just do instead: Dim arrColWidths(1)
without setting the datatype, but maybe there is a better way.
Sub Globals
Dim arrColWidths(0) As String
End Sub
Sub btnSQL_Click
Dim strColWidths
arrColWidths() = StrSplit(strColWidths, ",")
And after you get the datas... The output of the StrSplit Function is an String Array. You can't normaly put a string in a int64...
StrSplit=String Split and not Int64 Split
You can use this values on the attributes Width even if it's in String normaly...
Example:
B4X:
.Width=arrColWidths(0)
...=....
I hope it's helpfull...
Else you can also I think do this otherwise:
B4X:
pos=StrIndexOf(strColWidths,",",0)
Do While pos>-1
.Width=SubString(strColWidths,0,pos)
strColWidths=substring(strColsWidths,pos+1,StrLength(strColsWidths)-pos-1)
pos=StrIndexOf(strColWidths,",",0)
Loop
But it's longer... (And maybe there's an Error...)
Yes, declaring the array as a string array seems to make sense.
Difference won't be noticeable in practice, but I suppose it is a bit faster.
Main thing is that I understand now what is going on in 6.9.
As written in an above post, what happened in previous versions was that although you declared the array as Int64 it was replaced with a strings array as the result of StrSplit.
So the performance here is exactly the same as before.
BTW, as of v6.90 it is recommended to declare numeric variables with the Number type (which maps to Double). The Number type should perform best.
What I found somewhat strange is that loop counter should be declared as Number. Strange as Number is a double and loop counters always will be integer numbers. Why are they/should they be declared as Number?
But the question keeps the same. Why are double variables better than integer as loop variables? Integer are shorter and so they should be modifiable much faster.
Erel, can you explain why double variables are the fastest?