ホーム > ライブラリ > Array > fArray_BaseN

ライブラリ

fArray_BaseN

***************************************************************
配列の基底を調整する

【引数】DataAry :データ配列
              Base_Row :1次元の配列のBase
              Base_Col :2次元の配列のBase
***************************************************************

Public Function fArray_BaseN(DataAry As Variant, Base_Row As Long, Optional Base_Col As Long = -1) As Variant
    
    Dim RetAry      As Variant
    
    Dim Row_L       As Long
    Dim Row_U       As Long
    Dim Col_L       As Long
    Dim Col_U       As Long
    Call fArray_Lbound_Ubound(DataAry, Row_L, Row_U, Col_L, Col_U)
    
    Dim CntDim  As Long
    CntDim = fArray_DimCount(DataAry)
    Select Case CntDim
    
    Case 1
        ReDim RetAry(Base_Row To Base_Row + Row_U - Row_L)
        
        Dim i   As Long
        For i = Row_L To Row_U
            RetAry(Base_Row + i - Row_L) = DataAry(i)
        Next
        
    Case 2
        Dim BaseCol As Long
        BaseCol = Base_Row
        If -1 <> Base_Col Then
            BaseCol = Base_Col
        End If
        
        ReDim RetAry(Base_Row To Base_Row + Row_U - Row_L, BaseCol To BaseCol + Col_U - Col_L)
        
        Dim j   As Long
        For j = Col_L To Col_U
            For i = Row_L To Row_U
                RetAry(Base_Row + i - Row_L, BaseCol + j - Col_L) = DataAry(i, j)
            Next
        Next
        
    End Select
    
    fArray_BaseN = RetAry
    
End Function

Array   2017/11/21   shono

この記事へのコメント

コメントを送る

 
※ メールは公開されません
Loading...
 画像の文字を入力してください