Passing Arrays from Sub to Program 
Author Message
 Passing Arrays from Sub to Program

    Hello,

    I have a Main Program where I defined the variables. One of this
variable is a multidimensional array. I call a Sub where I add the items to
the Array, but when I try to write the items from the Array I can't.

    I write the items from the Sub and I do it correctly but from the Main
Program not.

    Can anyone help me?

The code in the Sub is:
If (rsConsultaProductos("PR_Precio") <> rsLineasPedido("LI_PrecioU")) then

     LineasCambioPrecio (Columna, FilaLineasCambioPrecio) =
rsLineasPedido("LI_IdLinea")
     Response.Write (LineasCambioPrecio(columna,FilaLineasCambioPrecio) &
"<br>")
     Columna = Columna + 1
     LineasCambioPrecio (Columna, FilaLineasCambioPrecio) =
rsConsultaProductos("PR_PrecioOferta")
     Response.Write (LineasCambioPrecio(columna,FilaLineasCambioPrecio) &
"<br>")
     FilaLineasCambioPrecio = FilaLineasCambioPrecio + 1
     Redim LineasCambioPrecio (Columna, FilaLineasCambioPrecio)

     Validar = 4

End If

And in the main program:

for columna = 0 to ubound(LineasCambioPrecio,1)
   for fila = 0 to ubound(LineasCambioPrecio,2)
    Response.Write ("columna= " & columna & "fila=" & fila &
LineasCambioPrecio(columna, fila) & "<br>")
   next
 next

I defined the array in the main program (I think it's a global variable, not
a local variable).

Thank you very much



Sat, 25 Jan 2003 03:00:00 GMT  
 Passing Arrays from Sub to Program
    I know what was the problem;-) I used 'Redim' instead 'Redim  Preserve',
so ASP creates a new Array and my items were deleted;-(

diego gomez escribi en mensaje ...

Quote:
>    Hello,

>    I have a Main Program where I defined the variables. One of this
>variable is a multidimensional array. I call a Sub where I add the items to
>the Array, but when I try to write the items from the Array I can't.

>    I write the items from the Sub and I do it correctly but from the Main
>Program not.

>    Can anyone help me?

>The code in the Sub is:
>If (rsConsultaProductos("PR_Precio") <> rsLineasPedido("LI_PrecioU")) then

>     LineasCambioPrecio (Columna, FilaLineasCambioPrecio) =
>rsLineasPedido("LI_IdLinea")
>     Response.Write (LineasCambioPrecio(columna,FilaLineasCambioPrecio) &
>"<br>")
>     Columna = Columna + 1
>     LineasCambioPrecio (Columna, FilaLineasCambioPrecio) =
>rsConsultaProductos("PR_PrecioOferta")
>     Response.Write (LineasCambioPrecio(columna,FilaLineasCambioPrecio) &
>"<br>")
>     FilaLineasCambioPrecio = FilaLineasCambioPrecio + 1
>     Redim LineasCambioPrecio (Columna, FilaLineasCambioPrecio)

>     Validar = 4

>End If

>And in the main program:

>for columna = 0 to ubound(LineasCambioPrecio,1)
>   for fila = 0 to ubound(LineasCambioPrecio,2)
>    Response.Write ("columna= " & columna & "fila=" & fila &
>LineasCambioPrecio(columna, fila) & "<br>")
>   next
> next

>I defined the array in the main program (I think it's a global variable,
not
>a local variable).

>Thank you very much



Sun, 26 Jan 2003 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Passing arrays from a server-function/sub to a server -variable

2. Passing an array to a Sub procedure

3. Syntax - passing array to a sub

4. Passing an array to a sub or function I get type mismatch

5. pass an array as function/sub argument

6. Question on passing array parameters to VB.NET Sub/Function

7. Problem in passing datarow array from one sub to other

8. Help! Problem passing string array to sub

9. Passing Property Arrays to Sub Routines

10. vb5 Passing an array of type MENU to a Sub

11. How to pass array into Sub?

12. Passing Control Arrays to Sub-Procedures

 

 
Powered by phpBB® Forum Software