rfresh Well-Known Member Licensed User Longtime User Jan 5, 2019 #1 Is there a function to explode a string into an array? If I have a string like this: "This is a test" Can I explode it into an array where each element of the array contains each character? Thank you...
Is there a function to explode a string into an array? If I have a string like this: "This is a test" Can I explode it into an array where each element of the array contains each character? Thank you...
tuhatinhvn Active Member Licensed User Longtime User Jan 5, 2019 #2 did you try with list? B4X: Dim chuoi As String chuoi="This is a test" Dim mang As List mang.Initialize For i=0 To chuoi.Length-1 mang.Add(chuoi.SubString2(i,i+1)) Next Log(mang) Upvote 0
did you try with list? B4X: Dim chuoi As String chuoi="This is a test" Dim mang As List mang.Initialize For i=0 To chuoi.Length-1 mang.Add(chuoi.SubString2(i,i+1)) Next Log(mang)
rfresh Well-Known Member Licensed User Longtime User Jan 5, 2019 #3 Yes, a list will work...thank you... Upvote 0
rfresh Well-Known Member Licensed User Longtime User Jan 5, 2019 #4 How do I access an element in the list? mang(0) or mang[0] isn't correct? Upvote 0
klaus Expert Licensed User Longtime User Jan 5, 2019 #5 mang.Get(0) You could also use an Array of Strings: B4X: Dim chuoi As String chuoi = "This is a test" Dim mang(chuoi.Length) As String For i = 0 To chuoi.Length - 1 mang(i) = chuoi.SubString2(i, i + 1)) Next and then use mang(index) to access each value Last edited: Jan 5, 2019 Upvote 0
mang.Get(0) You could also use an Array of Strings: B4X: Dim chuoi As String chuoi = "This is a test" Dim mang(chuoi.Length) As String For i = 0 To chuoi.Length - 1 mang(i) = chuoi.SubString2(i, i + 1)) Next and then use mang(index) to access each value