interlnk Member Licensed User Dec 18, 2017 #1 I try an array in B4a, but there is an error. The code could be similar to this: Dim i As Int Dim text As String Dim arr() As String text = "hola" For i = 1 To 20 arr(i) = text & i Next What's wrong?
I try an array in B4a, but there is an error. The code could be similar to this: Dim i As Int Dim text As String Dim arr() As String text = "hola" For i = 1 To 20 arr(i) = text & i Next What's wrong?
Star-Dust Expert Licensed User Longtime User Dec 18, 2017 #2 B4X: Dim i As Int Dim text As String Dim arr(20) As String ' define a size text = "hola" For i = 0 To 19 arr(i) = text & (i + 1) Next Upvote 0
B4X: Dim i As Int Dim text As String Dim arr(20) As String ' define a size text = "hola" For i = 0 To 19 arr(i) = text & (i + 1) Next
Cableguy Expert Licensed User Longtime User Dec 18, 2017 #3 Arrays index start at ZERO so an array that holds 20 items will be indexed from 0 to 19. In code we tend to use For X = 0 to Array.Lenght -1 where length hold the number of items in the array Upvote 0
Arrays index start at ZERO so an array that holds 20 items will be indexed from 0 to 19. In code we tend to use For X = 0 to Array.Lenght -1 where length hold the number of items in the array
Erel B4X founder Staff member Licensed User Longtime User Dec 19, 2017 #4 Tip: prefer Lists over arrays. Upvote 0