Consulting

Results 1 to 6 of 6

Thread: Popup when calling function

  1. #1
    VBAX Regular
    Joined
    Jan 2013
    Posts
    19
    Location

    Popup when calling function

    Dear all,

    I would like to have a function that, when being written from a module, will display a list of available choices for the arguments.

    What I would like is to have the same effect as when one writes the calling line of a function and comes to an argument that should be a boolean. Then comes a mini popup giving the choice True/False. I would like that to have the same but for a selection of 3 possibilities.

    I am not sure if I explain this clearly enough...

    Is this kind of possibility available? Maybe using Types? I've never used them before...

    Thanks in advance for you help!

  2. #2
    Like so:

    Option Explicit
    Public Enum eTest
        Value1
        Value2
        Value3
    End Enum
    
    Public Function Foo(MyArg As eTest)
        MsgBox MyArg
    End Function
    Regards,

    Jan Karel Pieterse
    Excel MVP jkp-ads.com

  3. #3
    VBAX Guru Kenneth Hobs's Avatar
    Joined
    Nov 2005
    Location
    Tecumseh, OK
    Posts
    4,956
    Location
    Public Type eTest
        Value1 As Boolean
        Value2 As Boolean
        Value3 As Boolean
    End Type
    
    Sub Test()
        Dim x As eTest, a() As Variant
        With x
            .Value1 = True
            .Value2 = False
            .Value3 = True
            a() = Array("x.Value1: " & .Value1, "x.Value2: " & .Value2, "x.Value3: " & .Value3)
            MsgBox Join(a(), vbLf)
        End With
    End Sub

  4. #4
    VBAX Regular
    Joined
    Jan 2013
    Posts
    19
    Location
    Hello both,

    Thank you Jan, this is exactly what I was looking for! I didn't expect my explanation to be clear enough, but it looks like it was just fine

    Cheers!

  5. #5
    Note that's behind the scenes, Value1 = 0, Value 2 = 1 and Value3 = 2. You can assign custom values like so:
    Public eNum eTest
        Value1=10
        Value2=20
        Value3=30
    End Enum
    Regards,

    Jan Karel Pieterse
    Excel MVP jkp-ads.com

  6. #6
    VBAX Regular
    Joined
    Jan 2013
    Posts
    19
    Location
    thanks for the update !

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •