Quantcast
Channel: Xojo Programming Forum - Latest topics
Viewing all articles
Browse latest Browse all 3791

Arrays

$
0
0

Forgive me if this is already possible in Xojo (I’m new to the language). I have an array that I’d like to search. See my code and comments below:

Dim arr() As String = Array(“Bill”, “Jane”, “Harry”, “Christopher”, “William”)

// My example adds only those names in the array that contain the letter “a” to a ListBox.
// This code works fine in Xojo.
ListBox1.RemoveAllRows
For Each item As String In arr
if item.Contains(“a”, ComparisonOptions.CaseInsensitive) then ListBox1.AddRow(item)
next

// New Feature Request:
// Update the Array keyword as follows (it would be overloaded):
// Array.FindAll(targetArray() As variant, searchFor As Variant)
// Array.FindAll(targetArray() As variant, searchFor As Variant, options As ComparisonOptions)
// Adding this functionality to the Array keyword eliminates the explicit check I had to write in the above example.
ListBox1.RemoveAllRows
For Each x as String In Array.FindAll(arr, “a”, ComparisonOptions.CaseInsensitive)
ListBox1.AddRow(x)
next

3 posts - 3 participants

Read full topic


Viewing all articles
Browse latest Browse all 3791

Trending Articles