R RB Smissaert Well-Known Member Licensed User Longtime User Apr 21, 2010 #1 Before 6.9 I could do: Sub Globals Dim arrColWidths(1) As Int64 End Sub Sub btnSQL_Click Dim strColWidths arrColWidths() = StrSplit(strColWidths, ",") But that now gives: Error compiling program. 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. RBS
Before 6.9 I could do: Sub Globals Dim arrColWidths(1) As Int64 End Sub Sub btnSQL_Click Dim strColWidths arrColWidths() = StrSplit(strColWidths, ",") But that now gives: Error compiling program. 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. RBS
M mjcoon Well-Known Member Licensed User Apr 21, 2010 #2 RB Smissaert said: Dim arrColWidths(1) As Int64 Click to expand... Well, StrSplit is defined to return an array of strings, and the 6.90 help suggests declaring the array explicitly as such. So it is a bit unfair to expect an implicit conversion! Especially as it would fail if any of the split strings happened not to be numeric... No doubt you could do it before merely because the "Int64" was actually ignored and what you got was an array of strings regardless. Mike.
RB Smissaert said: Dim arrColWidths(1) As Int64 Click to expand... Well, StrSplit is defined to return an array of strings, and the 6.90 help suggests declaring the array explicitly as such. So it is a bit unfair to expect an implicit conversion! Especially as it would fail if any of the split strings happened not to be numeric... No doubt you could do it before merely because the "Int64" was actually ignored and what you got was an array of strings regardless. Mike.
R RB Smissaert Well-Known Member Licensed User Longtime User Apr 21, 2010 #3 Yes, I found this now in the What is new section of the help: Backwards compatibility issues: · The type of arrays and structures cannot be changed after the first declaration. RBS
Yes, I found this now in the What is new section of the help: Backwards compatibility issues: · The type of arrays and structures cannot be changed after the first declaration. RBS
S sitajony Active Member Licensed User Apr 21, 2010 #4 Hi, I'm not sure but maybe you can write this: Code: Copy 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: Code: Copy .Width=arrColWidths(0) ...=.... I hope it's helpfull... Else you can also I think do this otherwise: Code: Copy 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...) Good luck
Hi, I'm not sure but maybe you can write this: Code: Copy 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: Code: Copy .Width=arrColWidths(0) ...=.... I hope it's helpfull... Else you can also I think do this otherwise: Code: Copy 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...) Good luck
R RB Smissaert Well-Known Member Licensed User Longtime User Apr 21, 2010 #5 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. RBS
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. RBS
Erel B4X founder Staff member Licensed User Longtime User Apr 22, 2010 #6 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.
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.
R RB Smissaert Well-Known Member Licensed User Longtime User Apr 22, 2010 #7 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? RBS
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? RBS
agraham Expert Licensed User Longtime User Apr 22, 2010 #8 RB Smissaert said: loop counters always will be integer numbers. Click to expand... That is not necessarily so. It is possible, and sometimes desirable, to have non-integer For loops. For a = 1.234 To 8.756 Step 0.013 ... Next might be quite useful in some circumstances
RB Smissaert said: loop counters always will be integer numbers. Click to expand... That is not necessarily so. It is possible, and sometimes desirable, to have non-integer For loops. For a = 1.234 To 8.756 Step 0.013 ... Next might be quite useful in some circumstances
corwin42 Expert Licensed User Longtime User Apr 22, 2010 #9 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?
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?
Erel B4X founder Staff member Licensed User Longtime User Apr 23, 2010 #10 Currently all numeric calculations are done internally with doubles. Therefore it is best to use doubles.
Currently all numeric calculations are done internally with doubles. Therefore it is best to use doubles.
R RB Smissaert Well-Known Member Licensed User Longtime User Apr 23, 2010 #11 That is not necessarily so Click to expand... Sure, but I have never used non-integer loop counters and it seems to make sense to be able to use an integer loop counter. RBS
That is not necessarily so Click to expand... Sure, but I have never used non-integer loop counters and it seems to make sense to be able to use an integer loop counter. RBS