0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

リスト追加

Last updated at Posted at 2025-04-26

リストの追加を実施。
現状はリストとsDictionary型を使用。キーが存在する場合は更新指定に従う。

'------------------------------------------------------------------------------
' リスト追加
'------------------------------------------------------------------------------
Public Function F_List_GetAdd( _
        ByRef aRtn As Dictionary, _
        ByVal aKey As Variant, _
        ByVal aItem As Variant, _
        Optional ByVal aUpdtFlg As Boolean = True) As Boolean
    Dim wkRtn As Dictionary: Set wkRtn = aRtn
    
    '引数チェック
    Select Case VarType(aKey)
        Case vbEmpty, vbNull
            '上記以外にもあるがそもそも指定しないので問題なし
            Exit Function
        Case Else
            '問題なし
    End Select
    
    'リスト生成
    If wkRtn Is Nothing Then
        Set wkRtn = New Dictionary
    End If
    
    With wkRtn
        'キーが存在しない場合
        If .Exists(aKey) <> True Then
            .Add aKey, aItem
        'キーが存在する場合
        Else
            '更新許可ならば上書き
            If aUpdtFlg = True Then
                M_Common.S_SetItem .Item(aKey), aItem
            Else
                Exit Function
            End If
        End If
    End With
    
    Set aRtn = wkRtn
    F_List_GetAdd = True
End Function
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?