[AccessD] OT: Passing an Array in VBA

Jurgen Welz jwelz at hotmail.com
Sun Dec 19 20:38:23 CST 2010


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 		 	   		  


More information about the AccessD mailing list