Wrox Programmer Forums
|
VB.NET 2002/2003 Basics For coders who are new to Visual Basic, working in .NET versions 2002 or 2003 (1.0 and 1.1).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB.NET 2002/2003 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 4th, 2004, 11:14 AM
Registered User
 
Join Date: Apr 2004
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default Passing an array in a Sub

Does anyone know how the code for passing an array to a sub or function is written.

If possible would you just show a sample snippit of the call and the sub, so I can understand how it works with an array.

I appreciate all your help.

Thanks,

Fred

F. Krantz
 
Old May 4th, 2004, 01:29 PM
Authorized User
 
Join Date: Mar 2004
Posts: 61
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Try this example:

Public Sub Button1_Click(byval as System.Object, byval e as System.EventArgs) Handles Button1.click
    Dim myArray(3) as string
    'Fill array elements
    myArray(0) = "Test0"
    myArray(1) = "Test1"
    myArray(2) = "Test2"
    myArray(3) = "Test3"

    'Pass Array
    Call PassArray(myArray)
End Sub

Private Sub PassArray(byval TestArray() as string)
    dim i as integer
    'Show each array element
    for i = 0 to TestArray.GetUpperBound(0)
        console.writeline(TestArray(i))
    next
End Sub





Similar Threads
Thread Thread Starter Forum Replies Last Post
passing parameter array Maryann BOOK: Access 2003 VBA Programmer's Reference 0 December 4th, 2006 10:56 AM
Passing a Array in of no specifc type.. John Pennington Pro VB 6 1 September 27th, 2006 05:04 PM
Passing an array to a Sub or Function donrafeal Access VBA 2 May 11th, 2006 09:39 AM
Passing php array values to javascript array gkrishna Pro PHP 0 November 6th, 2004 03:20 AM
Passing an Array of Strings to a WebService rmau Excel VBA 0 October 27th, 2003 03:59 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.