' Quick and easy String Array Constructor for VB5/6
' StrArray sArr(), 0, "A", "B", "C", "D"
' This subroutine is a string substitute for the VB6 variant Array constructor.
' The paramarray argument is still an array of variants, but is temporary and
' is a valid argument for VB5.
' StrArray sArr(), lb, paramarray
' The sArr() argument is any declared string array - empty or otherwise.
' The lb argument specifies the desired lower-bound of the first element.
' The paramarray argument is a comma-delimited list of strings that
' are assigned to the elements of the passed array. If no string
' arguments are specified, an un-initialized array is returned.
' Dim sArr() As String
' StrArray sArr(), 1, "A", "B", "C"
' Debug.Print sArr(2) ' "B"
Sub StrArray(sArr() As String, ByVal lb As Long, ParamArray Strings())
Dim i As Long, ub As Long
Erase sArr()
ub = UBound(Strings)
If ub = -1 Then Exit Sub
ReDim sArr(lb To lb + ub) As String
Do Until i > ub
sArr(i + lb) = Strings(i)
i = i + 1
Loop
End Sub
' Quick and easy Long Array Constructor for VB5/6
' LongArray lArr(), 0, 100, 200, 300, 400
' This sub is a long integer substitute for the VB6 variant Array constructor.
' The paramarray argument is still an array of variants, but is temporary and
' is a valid argument for VB5.
' LongArray lArr(), lb, paramarray
' The lArr() argument is any declared long array - empty or otherwise.
' The lb argument specifies the desired lower-bound of the first element.
' The paramarray argument is a comma-delimited list of whole numbers that
' are assigned to the elements of the passed long array. If no paramarray
' arguments are specified, an un-initialized array is returned.
' Dim lArr() As Long
' LongArray lArr(), 1, 181, 182, 183
' Debug.Print lArr(2) ' 182
Sub LongArray(lArr() As Long, ByVal lb As Long, ParamArray Longs())
Dim i As Long, ub As Long
Erase lArr()
ub = UBound(Longs)
If ub = -1 Then Exit Sub
ReDim lArr(lb To lb + ub) As String
Do Until i > ub
lArr(i + lb) = Longs(i)
i = i + 1
Loop
End Sub
|