VBA, MS Access MS Access в примерах

Функция добавления узла

Function AddNode(ctlTreeView As Control, strKey As String, strNameKey As String, _
                Optional varRelative As Variant = Null, _
                Optional rshRelationship As Integer = 4, _
                Optional varImage As Variant = Null, _
                Optional varSelectedImage As Variant = Null) As Boolean
' Универсальная функция добавления узла  - Возвращает True | False
' -------------------------------------------------------------------------------------------------/
Dim objNode As Object
Dim intQuality As Integer

On Error GoTo Err_AddNode

    intQuality = IIf(IsNull(varRelative), 0, 1) + IIf(IsNull(varImage), 0, 2) + IIf(IsNull(varSelectedImage), 0, 4)
    Select Case intQuality
        Case 0:   Set objNode = ctlTreeView.Nodes.Add(, , strKey, strNameKey)
        Case 1:   Set objNode = ctlTreeView.Nodes.Add(varRelative, rshRelationship, strKey, strNameKey)
        Case 2:   Set objNode = ctlTreeView.Nodes.Add(, , strKey, strNameKey)
        Case 3:   Set objNode = ctlTreeView.Nodes.Add(varRelative, rshRelationship, strKey, strNameKey)
        Case 4:   Set objNode = ctlTreeView.Nodes.Add(, , strKey, strNameKey)
        Case 5:   Set objNode = ctlTreeView.Nodes.Add(varRelative, rshRelationship, strKey, strNameKey)
        Case 6:   Set objNode = ctlTreeView.Nodes.Add(, , strKey, strNameKey)
        Case 7:   Set objNode = ctlTreeView.Nodes.Add(varRelative, rshRelationship, strKey, strNameKey)
    End Select
    
   AddNode = True

Exit_AddNode:
    Set objNode = Nothing
    Exit Function

Err_AddNode:
    Resume Exit_AddNode
End Function

Назад ToTop
L.E. 13.07.2023
Рейтинг@Mail.ru