Copy an array

rbw152

Member
Licensed User
Longtime User
Hi guys

I've been trying to find a way around this but I don't think there's an easy way, however I'd love to be proved wrong!

My question is: how do you copy an array to another one? I have a class whose main sub returns an array. How do I use the array it returns?

If I just declare another array variable outside my class and then say array1 = classarray it fails.

Is there an easy way around this?

Thanks very much.
 

margret

Well-Known Member
Licensed User
Longtime User
This will work!

Calling Class Sub:
B4X:
Dim ar() As String
ar = SF.Split2("This is a test to see if this works.", " ")
InputList(ar, "Results", -1)

Sub in Class:
B4X:
Sub Split2(CurrentString As String, Split_At_Delimiter As String) As String() '<- Notice this rank for return after the As String.
   '*** Function by RBSoft
   Dim t() As String
   t = Regex.Split(Split_At_Delimiter, CurrentString)
   Return t
End Sub
 
Upvote 0

rbw152

Member
Licensed User
Longtime User
Thanks a lot Margret, it did work.

I was hoping that there would be a built-in way to do this but obviously this is not the case.

Thanks for your hep.
 
Upvote 0
Top