rbw152 Member Licensed User Longtime User Apr 15, 2013 #1 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.
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 Apr 15, 2013 #2 This will work! Calling Class Sub: Code: Copy Dim ar() As String ar = SF.Split2("This is a test to see if this works.", " ") InputList(ar, "Results", -1) Sub in Class: Code: Copy 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
This will work! Calling Class Sub: Code: Copy Dim ar() As String ar = SF.Split2("This is a test to see if this works.", " ") InputList(ar, "Results", -1) Sub in Class: Code: Copy 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
rbw152 Member Licensed User Longtime User Apr 16, 2013 #3 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
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.
Erel B4X founder Staff member Licensed User Longtime User Apr 16, 2013 #4 If I just declare another array variable outside my class and then say array1 = classarray it fails. Click to expand... Can you post your code? It should work. Do you really want to copy the array? Or you just need to pass the array? Upvote 0
If I just declare another array variable outside my class and then say array1 = classarray it fails. Click to expand... Can you post your code? It should work. Do you really want to copy the array? Or you just need to pass the array?