Array Differences as Parameters

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • acuttitta@railvan.com

    #1

    Array Differences as Parameters

    [Pardon the crosspost, but it's warranted: A97/VBA5 & MapPoint2004]
    Is there a difference in populating arrays between the following two
    fashions?

    EXAMPLE 1
    varColors = Array("Blue", "Yellow", "Red")

    EXAMPLE 2
    rstColors = "tblColors" (which is populated with one record for each
    color)

    For intX = 1 to rstColors.Recor dCount
    varColors(intX) = rstColors!Color (assume array is properly dim'd)
    rstColors.MoveN ext
    Next intX

    Has anyone ran into difficulty with passing an array into a procedure's
    parameter (that calls for an array)? I'm trying to do some automation
    with MapPoint, and am running into the issue where Example 1 is the
    ONLY method that works. (For those who've used MP, I'm passing the
    array to the ArrayOfCustomFi elds parameter in DisplayDataMap. )

    I've noticed in the immediate pane that the two methods populate
    slightly differently so that the "Type" in Ex#1 shows "Variant/Variant"
    and #2 just shows "Variant". Beyond that, I see no difference.

    I'm ardent against ugly code. For this procedure, it's not just a
    simple text string I'm passing but instead an ugly calculation, causing
    (with line continuations) eight blocky lines of code. I'd much rather
    a nice clean loop to populate the array, but MP refuses to use it.

    Help appreciated in advance.

    Thanks,
    Anthony.

  • Lance Wynn

    #2
    Re: Array Differences as Parameters

    What error are you receiving? And what method in MP are you calling?

    I believe Arrays are 0 Based, which means the first element in example1 is
    varColors(0) = "Blue"
    in example 2, the first element varColors(0) = ""


    for your example 2 loop try:

    dim intX as integer
    do until rstColors.eof
    varColors(intX) = rstColors!Color (assume array is properly dim'd)
    intX=intX+1
    rstColors.MoveN ext
    loop

    <acuttitta@rail van.com> wrote in message
    news:1112051013 .596616.31740@z 14g2000cwz.goog legroups.com...
    [Pardon the crosspost, but it's warranted: A97/VBA5 & MapPoint2004]
    Is there a difference in populating arrays between the following two
    fashions?

    EXAMPLE 1
    varColors = Array("Blue", "Yellow", "Red")

    EXAMPLE 2
    rstColors = "tblColors" (which is populated with one record for each
    color)

    For intX = 1 to rstColors.Recor dCount
    varColors(intX) = rstColors!Color (assume array is properly dim'd)
    rstColors.MoveN ext
    Next intX

    Has anyone ran into difficulty with passing an array into a procedure's
    parameter (that calls for an array)? I'm trying to do some automation
    with MapPoint, and am running into the issue where Example 1 is the
    ONLY method that works. (For those who've used MP, I'm passing the
    array to the ArrayOfCustomFi elds parameter in DisplayDataMap. )

    I've noticed in the immediate pane that the two methods populate
    slightly differently so that the "Type" in Ex#1 shows "Variant/Variant"
    and #2 just shows "Variant". Beyond that, I see no difference.

    I'm ardent against ugly code. For this procedure, it's not just a
    simple text string I'm passing but instead an ugly calculation, causing
    (with line continuations) eight blocky lines of code. I'd much rather
    a nice clean loop to populate the array, but MP refuses to use it.

    Help appreciated in advance.

    Thanks,
    Anthony.


    Comment

    • acuttitta@railvan.com

      #3
      Re: Array Differences as Parameters

      Sorry, was a typo, only because I've tried both 0-based and 1-based
      arrays.

      Either way: "The parameter is incorrect."

      Comment

      Working...