VBA Site contains VBA code to create macros in WORD EXCEL ACCESS OUTLOOK

 

Collections

 

Sub collecting()

Dim elements As New collection

elements.Add "string_one", "key_one"

elements.Add "string_two", "key_two"

MsgBox elements(1) & " & " & elements("key_one"), , "Index And Key"

MsgBox elements(2) & " & " & elements("key_two"), , "Index And Key"

elements.Add "string_three", "key_three"

elements.Add "string_four"

For Each element In elements

MsgBox element, , "Add to collection"

Next

elements.Add "string_before_one", , 1

For Each element In elements

MsgBox element, , "Add before"

Next

elements.Add "string_after_one", , , 2

For Each element In elements

MsgBox element, , "Add after"

Next

elements.Remove (1)

elements.Remove (2)

elements.Remove ("key_three")

elements.Remove (3)

For Each element In elements

MsgBox element, , "Remove"

Next

MsgBox "Collection counts: " & elements.Count & vbNewLine & elements.Item(1) & vbNewLine & elements.Item(2)

End Sub



Dodaj komentarz






Dodaj

© 2013-2024 PRV.pl
Strona została stworzona kreatorem stron w serwisie PRV.pl