|
Visual Basic (VB and VBA) |
|
Copyright 1999-2001 Christopher Greaves. All rights reserved. Home Page and email to [email protected] |
| If in doubt, record a macro and inspect the entrails! |
Please read the DISCLAIMER.
Here is an INDEX to all the procedures.
You will probably need one copy of my GLOBAL DECLARATIONS.
Public Function intRank(strAr() As String) As Integer
' Procedure : intRank
' Description: Return the integer rank of an array.
' By: Chris Greaves Inc.
' Inputs: Array
' Returns: INTEGER number of dimensions.
' Assumes: Nothing
' Side Effects: None.
' Tested: By the calls shown below.
Dim i As Integer ' Iterates through all possible dimensions.
For i = 1 To 32000 ' what the heck.
On Error GoTo Outer ' should trigger when the UBound fails.
intRank = UBound(strAr, i) ' need a bit-bucket here.
Next i
Outer:
On Error GoTo 0
intRank = i - 1 ' Error occurs when we are BEYOND our last dimension
'Sub TESTintRank()
'Dim strAr1(1) As String
'Debug.Print intRank(strAr1) '1
'Dim strAr2(2, 3) As String
'Debug.Print intRank(strAr2) '2
'Dim strAr3(4, 5, 6) As String
'Debug.Print intRank(strAr3) '3
'Dim strAr4(7, 8, 9, 0) As String
'Debug.Print intRank(strAr4) ' 4
'Dim strAr5(0, 0, 0, 0, 0) As String
'Debug.Print intRank(strAr5) '5
'End Sub
End Function
| We all knew nothing when we started … |
|
Home Page and Contact Information Send email to [email protected]. This page was last updated Thursday, November 15, 2001 |