Re: newbie: array passing problem

Tech-Archive recommends: Fix windows errors by optimizing your registry




"tom" <tadamsmar@xxxxxxxxx> wrote
Can I pass a one dimension of an array as an array?

While not exceptionally performant (it will be slower)
you might consider an array of arrays:

LFS

Option Explicit

Private Sub Form_Load()
Dim A As Variant, i, j

ReDimEx A, 3, 5, vbVSingle

For i = 0 To 3
For j = 0 To 5
A(i)(j) = i * j
Next j, i

FUBAR A(1)

End Sub

Sub FUBAR(ByVal Ary As Variant)
Dim i
For i = 0 To UBound(Ary)
Debug.Print Ary(i)
Next
End Sub

Sub ReDimEx(ByRef ArrayID As Variant, _
ByVal Row As Long, _
ByVal Col As Long, _
ByVal CellType As VBRUN.VariantTypeConstants)
Dim i As Long, A() As Long, B() As Single

ReDim ArrayID(0 To Row)

Select Case CellType
Case vbLong
For i = 0 To Row
ReDim A(0 To Col) As Long
ArrayID(i) = A
Next
Case vbSingle
For i = 0 To Row
ReDim B(0 To Col) As Single
ArrayID(i) = B
Next
End Select
End Sub


.



Relevant Pages

  • Re: Updated datestamp doesnt work
    ... Public Sub StoreMyOldVals ... ' store values of current row in array ... Dim dbs As DAO.Database, rst As DAO.Recordset ... Dim var As Variant ...
    (microsoft.public.access.gettingstarted)
  • Re: Updated datestamp doesnt work
    ... Public Sub StoreMyOldVals ... ' store values of current row in array ... Dim dbs As DAO.Database, rst As DAO.Recordset ... Dim var As Variant ...
    (microsoft.public.access.gettingstarted)
  • Re: Updated datestamp doesnt work
    ... Public Sub StoreMyOldVals ... ' store values of current row in array ... Dim dbs As DAO.Database, rst As DAO.Recordset ... Dim var As Variant ...
    (microsoft.public.access.gettingstarted)
  • Re: referencing/sorting arrays
    ... Public Sub SortArrayAscendAs Integer) ... 'Sort an array in ascending order ... Dim Idx01 As Integer ... >> If no data type declaration is made for the argument it becomes a variant. ...
    (microsoft.public.excel.programming)
  • Re: Max/Min Functions
    ... You said the Array function won't work here. ... Dim myArray() As Variant ... > Dim vMax As Variant ...
    (microsoft.public.word.vba.general)