TheSwamp

Code Red => VB(A) => Topic started by: Guest on October 23, 2007, 12:24:03 PM

Title: LSP Member Equivalent in VBA?
Post by: Guest on October 23, 2007, 12:24:03 PM
Is there an equivalent to LSPs MEMBER function in VBA?  I thought I saw something (either a built-in function or a separate function) but I can't remember where or what it's called.  I also have this funny feeling that I've posted this before (either here or another NG).  :|

Thanks.
Title: Re: LSP Member Equivalent in VBA?
Post by: MP on October 23, 2007, 12:36:35 PM
You can replicate functionality, depending on particular use / need, using collections or dictionaries.
Title: Re: LSP Member Equivalent in VBA?
Post by: Fatty on October 23, 2007, 12:45:17 PM
Try this one

Code: [Select]
Option Explicit

Function IsMember(source As Variant, itm As Variant) As Boolean
    Dim idx As Variant

        On Error GoTo Err_Control

        For Each idx In source
            If (idx <> itm) Then
                IsMember = False
                Else
                IsMember = True
                Exit For
            End If
        Next

        Exit Function
Err_Control:
IsMember = False
End Function

~'J'~
Title: Re: LSP Member Equivalent in VBA?
Post by: MP on October 23, 2007, 12:46:56 PM
Variants, akkkk, my eyes!!

(sorry Fatty, not an advocate of variants)
Title: Re: LSP Member Equivalent in VBA?
Post by: Fatty on October 23, 2007, 01:13:57 PM
Variants, akkkk, my eyes!!

(sorry Fatty, not an advocate of variants)
I don't like 'em too but what can I do?
Cheers :)

~'J'~
Title: Re: LSP Member Equivalent in VBA?
Post by: MP on October 29, 2007, 07:46:40 AM
If this code isn't going to reside in a dll AND/Or directly exchange with LISP I don't understand why you use variants when explicit typing should prevail. Am I missing something?

In other words, as I understood the question, "What is the equivalent VB technique to mimic LISP's member function?", not "How do I pass a list to VB and have it perform a member type query?".

Could be me, surviving on crumbs of sleep.
Title: Re: LSP Member Equivalent in VBA?
Post by: Fatty on October 29, 2007, 07:56:59 AM
Ah, I see
Sorry, my bad
In this case I have not have an answer :(

~'J'~
Title: Re: LSP Member Equivalent in VBA?
Post by: MP on October 29, 2007, 09:03:39 AM
No worries my friend. Like I said, there's a good chance I'm misunderstanding the intent so perhaps it's best to wait and see if the original poster clarifies.
Title: Re: LSP Member Equivalent in VBA?
Post by: Fatty on October 29, 2007, 09:20:20 AM
Thanks Michael,
I guess he is busy with own job

Regards,

Oleg

~'J'~