Results 1 to 5 of 5

Thread: Arrays

  1. #1
    Join Date
    Mar 2002
    Posts
    192

    Unanswered: Arrays

    This is more of an VB problem but i am doing this in Access so I'm making the post here.

    QUESTION: If a function is of type String Array (i.e. string() ) is there any way to reference an element without VB thinking i'm trying to call the function again recursively?


    For example...

    Public Function Test (MyVar as Long) as string()
    ' The next line of code needs to reference an element in the array
    ' Not call Test again recursively.
    ' When run VB thinks i'm trying to call test again and pass in 0

    Test(0) = "I want to pop this string into the first element"
    End Function

  2. #2
    Join Date
    Nov 2002
    Location
    Ohio
    Posts
    90
    Functions were designed to return a single object or variable.

    The best thing I can suggest is:

    Public Sub Test(tmpLong as long, tmpTest() as string)

    tmptest(0)=somefunction(tmpLong)

    End Sub

    Can you elaborate on why you want an array returned from a function?

    Goos Luck,
    Bruce Baasch

  3. #3
    Join Date
    Mar 2002
    Posts
    192
    This probably won't mean much as you pretty much need to have the system requirements to see why I need this but I am building an Integration Utility. The first element holds the File header. and any other element that comes after that holds SQL statement fragments (which can vary from 1 to X). It looks like i'll be using a function that is of type "user defined" and place my array there.

  4. #4
    Join Date
    Nov 2002
    Location
    Ohio
    Posts
    90
    You could return the address of the array instead of the array.

    Or return a string containing query arguments separated by some type of delimiter.

    These aren't "smooth", but might get you by.

    Good Luck,
    Bruce Baasch

  5. #5
    Join Date
    Mar 2002
    Posts
    192
    Hi Bruce:

    I realized afterwards that your first suggestion would work best and i've changed my code to reflect that model. Thanks for your help.

Posting Permissions

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