nfordbscndrd Well-Known Member Licensed User Longtime User Jan 31, 2011 #1 In Global: Dim Cards(52) As Int In Activity_Create: Cards(52) = someNumber Error when app is compiled-run: java.lang.ArrayIndexOutOf BoundsException How can 52 be an out-of-bounds index when I Dimmed it to 52?
In Global: Dim Cards(52) As Int In Activity_Create: Cards(52) = someNumber Error when app is compiled-run: java.lang.ArrayIndexOutOf BoundsException How can 52 be an out-of-bounds index when I Dimmed it to 52?
stevel05 Expert Licensed User Longtime User Feb 1, 2011 #3 As TOB suggested when you dimension an array of size 52, it actually has 52 elements. It's just that the first one is element 0. So 0 to 51 = 52 elements. Steve
As TOB suggested when you dimension an array of size 52, it actually has 52 elements. It's just that the first one is element 0. So 0 to 51 = 52 elements. Steve
nfordbscndrd Well-Known Member Licensed User Longtime User Feb 1, 2011 #4 stevel05 said: As TOB suggested when you dimension an array of size 52, it actually has 52 elements. It's just that the first one is element 0. So 0 to 51 = 52 elements. Click to expand... In any version of BASIC I've ever used, 52 is the last index number, not the number of elements, so Dim A(52) is 0-52 in other BASICs. In fact, I am in the process of converting a Visual Basic program and its got a ton of arrays dimensioned, all to the last index number. Anyway, it just means that I'll have to change all those Dim's by upping their values by one.
stevel05 said: As TOB suggested when you dimension an array of size 52, it actually has 52 elements. It's just that the first one is element 0. So 0 to 51 = 52 elements. Click to expand... In any version of BASIC I've ever used, 52 is the last index number, not the number of elements, so Dim A(52) is 0-52 in other BASICs. In fact, I am in the process of converting a Visual Basic program and its got a ton of arrays dimensioned, all to the last index number. Anyway, it just means that I'll have to change all those Dim's by upping their values by one.
T TOB Member Licensed User Longtime User Feb 3, 2011 #5 Well, in almost any other languages an array is zero-based and the dimension indicates number of elements not he last one. I'm also using PowerBasic for Windows and it's just the same thing there. See this Java info: Arrays (The Java™ Tutorials > Learning the Java Language > Language Basics)
Well, in almost any other languages an array is zero-based and the dimension indicates number of elements not he last one. I'm also using PowerBasic for Windows and it's just the same thing there. See this Java info: Arrays (The Java™ Tutorials > Learning the Java Language > Language Basics)
nfordbscndrd Well-Known Member Licensed User Longtime User Feb 3, 2011 #6 TOB said: Well, in almost any other languages an array is zero-based and the dimension indicates number of elements not he last one. I'm also using PowerBasic for Windows and it's just the same thing there. Click to expand... Well, I guess that on the B4A home page, they should change "Basic4android language is similar to Visual Basic" to "...PowerBasic". <grin> It seems like 99% of B4A's syntax and way of doing things is different from VB.
TOB said: Well, in almost any other languages an array is zero-based and the dimension indicates number of elements not he last one. I'm also using PowerBasic for Windows and it's just the same thing there. Click to expand... Well, I guess that on the B4A home page, they should change "Basic4android language is similar to Visual Basic" to "...PowerBasic". <grin> It seems like 99% of B4A's syntax and way of doing things is different from VB.
agraham Expert Licensed User Longtime User Feb 3, 2011 #7 nfordbscndrd said: B4A's syntax and way of doing things is different from VB. Click to expand... It may be different to VB6 but it is similar in many ways (including array declarations!) to VB.NET which has been around for nine years now.
nfordbscndrd said: B4A's syntax and way of doing things is different from VB. Click to expand... It may be different to VB6 but it is similar in many ways (including array declarations!) to VB.NET which has been around for nine years now.
nfordbscndrd Well-Known Member Licensed User Longtime User Feb 3, 2011 #8 agraham said: It may be different to VB6 but it is similar in many ways (including array declarations!) to VB.NET which has been around for nine years now. Click to expand... VB.NET hardly qualifies as the same language as the original Visual Basic 1-6, which is why a huge number of VB6 programmers (including me) never made the change. Maybe the B4A home page should change from "similar to Visual Basic" to "similar to VB.NET" (seriously).
agraham said: It may be different to VB6 but it is similar in many ways (including array declarations!) to VB.NET which has been around for nine years now. Click to expand... VB.NET hardly qualifies as the same language as the original Visual Basic 1-6, which is why a huge number of VB6 programmers (including me) never made the change. Maybe the B4A home page should change from "similar to Visual Basic" to "similar to VB.NET" (seriously).