VERSION 5.00
Begin VB.Form Form1 
   Caption         =   "Form1"
   ClientHeight    =   3195
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   4680
   LinkTopic       =   "Form1"
   ScaleHeight     =   3195
   ScaleWidth      =   4680
   StartUpPosition =   3  'Windows Default
   Begin VB.ListBox List1 
      Height          =   2985
      Left            =   240
      TabIndex        =   0
      Top             =   120
      Width           =   4215
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
 Function PowerSet(ByRef aryInput() As String) As String()

    Dim Result() As String
    Dim aryTemp() As String
    Dim cnt As Integer
    Dim intTemp As Integer
            
    ReDim Result(0)

    Result(0) = "{}"

    cnt = 1

        For i = 1 To UBound(aryInput) + 1
            aryTemp = PowerSetPart(i, aryInput)

            ReDim Preserve Result(UBound(Result) - 1 + UBound(aryTemp) + 2)
            For j = 0 To UBound(aryTemp)
                Result(cnt) = "{" & aryTemp(j) & "}"
                cnt = cnt + 1
            Next
        Next

    PowerSet = Result

End Function

 Function PowerSetPart(ByVal intLength As Integer, ByRef aryInput() As String) As String()
    Dim Result() As String
    Dim cnt As Integer
    Dim cnt2 As Integer
    Dim aryTemp() As String
    Dim aryAdd() As String
    Dim intTemp As Integer
    

    cnt = 0
    cnt2 = 0

    If intLength = 0 Then

        ReDim Result(0)
        Result(0) = ""

    ElseIf intLength = 1 Then

        Result = aryInput

    Else

        ReDim Result(0)
        
        For i = 0 To UBound(aryInput) - intLength + 1

            cnt2 = 0
            ReDim aryTemp(UBound(aryInput) - i - 1)
            For j = i + 1 To UBound(aryInput)
                aryTemp(cnt2) = aryInput(j)
                cnt2 = cnt2 + 1
            Next

            aryAdd = PowerSetPart(intLength - 1, aryTemp)
            
            If UBound(Result) = 0 Then
                intTemp = -1
            Else
                intTemp = UBound(Result)
            End If
            
            ReDim Preserve Result(intTemp + UBound(aryAdd) + 1)
            For j = 0 To UBound(aryAdd)
                Result(cnt) = aryInput(i) & "," & aryAdd(j)
                cnt = cnt + 1
            Next

        Next

    End If

    PowerSetPart = Result

End Function


Private Sub Form_Load()

    Dim aryTest() As String
    ReDim aryTest(0)
    aryTest(0) = "1"
    'aryTest(1) = "2"
    'aryTest(2) = "3"
    
    Dim aryTemp() As String
    aryTemp = PowerSet(PowerSet(aryTest))

    For i = 0 To UBound(aryTemp)
        List1.AddItem aryTemp(i)
    Next
    
End Sub
