[Gambas-user] Remove Null or Empty items in arrays.
bsteers4 at gmail.com
Wed Jun 21 19:47:57 CEST 2023
On Wed, 21 Jun 2023, 17:37 Martín, <mbelmonte at belmotek.net> wrote:
> El 21/6/23 a las 13:08, Bruce Steers escribió:
> > Public Sub ArrayClean(MyArray As Variant) As Variant
> > Dim hArray As Variant = MyArray.Copy()
> > For c As Integer = hArray.Max DownTo 0
> > If Not hArray[c] Then hArray.Remove(c)
> > Next
> > Return hArray
> > End
> I like this code you propose, thank you.
> But I was wondering, since there is .Shuffle or .Sort, maybe it would be
> a good idea to have .RemoveEmpty.
For a string array it's even easier, you can simply use Array.Join() and
MyArray = Split(MyArray.Join("|"), "|", Null, True)
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the User