Results 1 to 3 of 3

Thread: pass array variables to a sub procedure

  1. #1

    Thread Starter
    Hyperactive Member oyad's Avatar
    Join Date
    Feb 2003
    Location
    PhoxWare MicroSystems
    Posts
    463

    pass array variables to a sub procedure

    i have this arrval(1) to arrval(6) and i want to pas the values to asub procedure.how will the call statement be like?ie
    call namepro(.....)
    and the sub name?ie
    private sub manepro(........)

  2. #2
    Need-a-life Member Mc Brain's Avatar
    Join Date
    Apr 2000
    Location
    Buenos Aires, Argentina
    Posts
    6,808
    VB Code:
    1. Option Explicit
    2. Option Base 1
    3.  
    4. Private Sub Form_Load()
    5.     Dim arrval(6) As String
    6.    
    7.     arrval(1) = "one"
    8.     arrval(2) = "two"
    9.     arrval(3) = "three"
    10.     arrval(4) = "four"
    11.     arrval(5) = "five"
    12.     arrval(6) = "six"
    13.    
    14.     PrintArr arrval
    15. End Sub
    16.  
    17. Private Sub PrintArr(arr() As String)
    18.     Dim i As Integer
    19.    
    20.     For i = 1 To UBound(arr)
    21.         Debug.Print arr(i)
    22.     Next i
    23.  
    24. End Sub
    Emiliano F. Martín


    If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
    Encourage the person who helped you to keep doing it, and give him the points he deserves.


    MP3 Organizer: Freeware to logically organize all your MP3s.

  3. #3
    PowerPoster BruceG's Avatar
    Join Date
    May 2000
    Location
    New Jersey (USA)
    Posts
    2,657
    The call will be:
    VB Code:
    1. namepro arrval(1), arrval(6)
    - or -
    VB Code:
    1. Call namepro(arrval(1), arrval(6))

    The look of the sub itself depends on the datatype of the array (String, Integer, etc.). Assuming it is string, the sub would look something like this:
    VB Code:
    1. Private Sub namepro(strArg1 As String, strArg2 As String)
    "It's cold gin time again ..."

    Check out my website here.

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