Android Question Array from range

MotoMusher

Active Member
Licensed User
Longtime User
Is there a way in B4A to create an array from a range, specifically letters? I can loop through the integers fine, but need to create arrays of varying lengths using letters. (C,D,E,F,G)

Converting a PHP site, and looking for a way to duplicate the following without typing it out

$arr = array_merge(range(0, 9), range("B", "Z"), range("g", "z"));

Thanks
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
B4X:
Sub Activity_Create(FirstTime As Boolean)
   Dim arr() As String = range("a", "z")
End Sub

Sub Range(First As Char, Last As Char) As String()
   Dim i1 As Int = Asc(first)
   Dim i2 As Int= Asc(last)
   Dim res(i2 + 1 - i1) As String
   For i = i1 To i2
     res(i - i1) = Chr(i)
   Next
   Return res
End Sub
 
Upvote 0
Top