View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
keepITcool keepITcool is offline
external usenet poster
 
Posts: 2,253
Default dynamic variables

Christian,

I think you need to look in vba help at
CALL, DIM, SUB and FUNCTION keywords..

the idea is you can pass them as arguments to functions
of procedures. VBA passes parameters ByReference (ByRef) as default


Sub Demo()
Dim myarray1() As String
Dim myarray2() As String

Upsizer myarray1, myarray1, 3
myarray1(0) = "a"
myarray1(1) = "b"
myarray1(2) = "c"

Upsizer myarray1, myarray2, 10

Debug.Print UBound(myarray1), UBound(myarray2)

End Sub


Sub Upsizer(vaIn, vaOut, incr As Integer)
Dim y&
vaOut = vaIn
On Error Resume Next
y = UBound(vaOut)
On Error GoTo 0
ReDim Preserve vaOut(y + incr)
End Sub


HTH

keepITcool

< email : keepitcool chello nl (with @ and .)
< homepage: http://members.chello.nl/keepitcool


"Christian Lehmann" wrote:

Hallo,

imagine that a dynamic variable has been specified with the statement:

dim feld() as string
dim z as integer

z shall be the variable to store the size of the dynamic variable.
During the runtime of the program the dynamic variable "feld" is
adjusted with the statement:

redim preserve feld(z)

Is there any possibility to transfer this variable to

1) another VBA-Function or VBA-Subroutine? (in C++ those fields are
transferred with the help of pointers, is there a similar possibility
in VBA?)

2) an external funktion that has been added by "declare" and uses C++
code. (I use MS Visual C++ 6.0).

I do not want to use global variables.

I apologize for my English and say thank you very any support in
advance!

Greetings,
Christian