Results 1 to 2 of 2

Thread: Passing KeyValues

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Oct 1999
    Location
    Hyderabad
    Posts
    23

    Post

    How to pass keyvalues along with their values into function as an array?
    ex:
    I want pass the informatin

    integer: Int1
    string: Str1
    long: Lng1
    variant : Var1
    integer: Int2
    string: Str2
    long: Lng2
    variant : Var2
    to a function fun1( Var as variant)

    where var(0) should be of type integer and its value is Int1
    var(1) should be of type integer and its value is Str1
    var(2) should be of type long and its value is Lng1
    var(3) should be of type variant and its value is Var1
    ....and so on

    please let me know ur ideas

    Thanks in advance
    Kiran
    krallabandi@india.osius.com

  2. #2
    Guru Aaron Young's Avatar
    Join Date
    Jun 1999
    Location
    Red Wing, MN, USA
    Posts
    2,176

    Post

    Try the ParamArray Keyword, eg.
    Code:
    Private Sub Command1_Click()
        MsgBox "You Passed " & MultiParams(1, "String", 3.5, 128000) & " Parameters."
    End Sub
    
    Private Function MultiParams(ParamArray aParams() As Variant) As Long
        Dim I As Integer
        MultiParams = UBound(aParams) + 1
        For I = 0 To MultiParams - 1
            MsgBox "Parameter " & (I + 1) & " = " & aParams(I) & " of Type (" & TypeName(aParams(I)) & ")"
        Next
    End Function
    ------------------
    Aaron Young
    Analyst Programmer
    aarony@redwingsoftware.com
    adyoung@win.bright.net

Posting Permissions

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



Click Here to Expand Forum to Full Width