Thread: Add to an Array
View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Edward Ulle Edward Ulle is offline
external usenet poster
 
Posts: 92
Default Add to an Array

If you want to try something different use a Collection as shown below.
I grows dynamically.

Option Explicit

Public Sub Test()

Dim chosenChkBox As Collection
Dim chkAA As Boolean
Dim chkBB As Boolean
Dim chkCC As Boolean
Dim i As Integer
Dim strTemp As String

chkAA = True
chkBB = False
chkCC = True

Set chosenChkBox = New Collection

If chkAA Then chosenChkBox.Add "AA"
If chkBB Then chosenChkBox.Add "BB"
If chkCC Then chosenChkBox.Add "CC"

For i = 1 To chosenChkBox.Count
strTemp = strTemp + chosenChkBox.Item(i) + vbCrLf
Next

MsgBox strTemp

Set chosenChkBox = Nothing

End Sub



*** Sent via Developersdex http://www.developersdex.com ***