If I filter my 1-based variant array it becomes 0-based. But I have a situation where it's not always needing filtering
so my check for Ubound > 0 fails if there only onw item in that array.
Is there any 'elegant' fix or solution ? Thanks
If I filter my 1-based variant array it becomes 0-based. But I have a situation where it's not always needing filtering
so my check for Ubound > 0 fails if there only onw item in that array.
Is there any 'elegant' fix or solution ? Thanks
How about >= 0
I've made this complicated. I'm using a routine that puts some filename into a 1 based array.
Then I filter the array to include (or remove) items matching some text.
But this leaves the first item either in element 0 or sometimes element 1.
Neither IsEmpty or Ubound seem to do what I want as they vary too.
How can I get the first item, or nothing, reliably after filtering?
You can refer to the array values via the index:
if array(0) =
if array(1) =
How are you building first array?
Why use 1-based array?
Why use array instead of recordset?
How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.
It's a collection of Filenames and the Function that builds it returns a 1-Based Array. I can't easily change that as other things use it.
Recordset?? Not quite with you.
I'm trying different things with the index as davegri suggested, But suspect if the array is empty... may need more.
Didn't know data was not in table.
In my test, second array is always 0-based when it has elements, which seems odd with Option Base 1 in header.
Could try an error handler. Set integer variable to UBound(ary2) or for value of ary(0), if it errors GoTo handler.
How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.
I was trying to avoid IFs for speed but this is all I can think of. I send in the filtered array and return the first item, or empty string.
Seems ok but still testing.
Code:Function ThePick(Arr) As String If UBound(Arr) > -1 Then If Arr(0) > "" Then ThePick = Arr(0) ElseIf UBound(Arr) > 0 Then If Arr(1) > "" Then ThePick = Arr(1) End If End If End Function