[AccessD] OT: Passing an Array in VBA]

Rocky Smolin rockysmolin at bchacc.com
Mon Dec 20 10:40:26 CST 2010


-------- Original Message --------
Subject: RE: [AccessD] OT: Passing an Array in VBA
From: <rockysmolin at bchacc.com>
Date: Sun, December 19, 2010 8:50 pm
To: "Access Developers discussion and problem solving"
<accessd at databaseadvisors.com>


At the risk of being flamed might I suggest  making the array Global -then
you don't have to pass it anywhere, it's available to the whole program as
is.  I know many people live in fear and loathing of globals but really,
they're quite innocuous.  Globals are our friends.

Rocky


 

-------- Original Message --------
Subject: Re: [AccessD] OT: Passing an Array in VBA
From: Jurgen Welz <jwelz at hotmail.com>
Date: Sun, December 19, 2010 7:38 pm
To: <accessd at databaseadvisors.com>


In Access VBA I always pass arrays to receiving variant variable without the
trailing (). I've had problems trying to pass them as arrays of a declared
type. I also generally rename the recieving variable even if passed By Ref.

Sub PopulateALICO(WerteIn As Variant, i As Integer)

This is exactly how I pass an array for processing, like to a sort
procedure. In the example below, I've got a form module level declared
variant, mvArTemplates, that needs to be sorted ascending or descending on
one of the columns. The sort procedure also receives the number of columns
to be received:

Caller:
qSort mvArTemplates, lngColumn, blnAsc, 4

SubRoutine"
Sub qSort(varAr As Variant, fld As Long, Asc As Boolean, NumberCol As Long,
Optional lngL As _
Long = -2, Optional lngR As Long = -2)

Ciao Jürgen Welz Edmonton, Alberta jwelz at hotmail.com



From: rlister at actuarial-files.com
To: accessd at databaseadvisors.com
Date: Sun, 19 Dec 2010 16:46:00 -0400
Subject: [AccessD] OT: Passing an Array in VBA

Hello,



Sorry to bother with an Excel 2007 problem.



I try to pass an three-dimensional-array Werte(I, j. k) to a Procedure,
manipulate Werte() there. Then the manipulated Werte()-Array is passed again
to the main program.



My Code:

The main program

Dim Werte(1 To 9, 1 To 42, 1 To 7) As Single

..

With Activesheet

Select Case .Range("D" & "" & i + 1 & "").Value

Case "ALICO"

PopulateALICO Werte:=Werte, i:=1

Case "ANTIGUA"

PopulateANTIGUA Werte:=Werte, i:=1

...

End Select



The called procedure

Sub PopulateALICO(ByRef Werte() As Single, i As Integer)

..

****************************************************************************
******

When I check in the main program, the array Werte() is still unmanipulated.



Saludos

Actuary Ralf Lister

La Paz, Bolivia

Registrado en ASFI

No. Registro: Act.Mat. 001

NIT: 1016725022

Skype Name: ralf.martin.lister

Tel.: 222 26 61, Cel. 70136531

rlister at actuarial-files.com

www.actuarial-files.com

Environment




-- AccessD mailing list AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd Website:
http://www.databaseadvisors.com 
-- 
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com





More information about the AccessD mailing list