Imports System
Public Class Test
Dim mvArr As Variant
Dim maResult() As String
Dim maInclude() As Long
Dim mlElementCount As Long
Dim mlResultCount As Long
Public Shared Sub Main()
' your code goes here
End Sub
Sub AllCombos()
Dim i As Long
'Initialize arrays and variables
Erase maInclude
Erase maResult
mlResultCount = 0
'Create array of possible substrings
mvArr = Array("NAME", "DESC", "DATE", "ACCOUNT")
'Initialize variables based on size of array
mlElementCount = UBound(mvArr)
ReDim maInclude(LBound(mvArr) To UBound(mvArr))
ReDim maResult(1 To 2 ^ (mlElementCount + 1))
'Call the recursive function for the first time
Eval 0
'Print the results to the immediate window
For i = LBound(maResult) To UBound(maResult)
Console.WriteLine i, maResult(i)
Next i
End Sub
Sub Eval(ByVal lPosition As Long)
Dim sConcat As String
Dim i As Long
If lPosition <= mlElementCount Then
'set the position to zero (don't include) and recurse
maInclude(lPosition) = 0
Eval lPosition + 1
'set the position to one (include) and recurse
maInclude(lPosition) = 1
Eval lPosition + 1
Else
'once lPosition exceeds the number of elements in the array
'concatenate all the substrings that have a corresponding 1
'in maInclude and store in results array
mlResultCount = mlResultCount + 1
For i = 0 To UBound(maInclude)
If maInclude(i) = 1 Then
sConcat = sConcat & mvArr(i) & Space(1)
End If
Next i
sConcat = Trim(sConcat)
maResult(mlResultCount) = sConcat
End If
End Sub
End Class
SW1wb3J0cyBTeXN0ZW0KClB1YmxpYyBDbGFzcyBUZXN0CgoKRGltIG12QXJyIEFzIFZhcmlhbnQKRGltIG1hUmVzdWx0KCkgQXMgU3RyaW5nCkRpbSBtYUluY2x1ZGUoKSBBcyBMb25nCkRpbSBtbEVsZW1lbnRDb3VudCBBcyBMb25nCkRpbSBtbFJlc3VsdENvdW50IEFzIExvbmcKCglQdWJsaWMgU2hhcmVkIFN1YiBNYWluKCkKCQknIHlvdXIgY29kZSBnb2VzIGhlcmUKCUVuZCBTdWIKClN1YiBBbGxDb21ib3MoKQoKICAgIERpbSBpIEFzIExvbmcKCiAgICAnSW5pdGlhbGl6ZSBhcnJheX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ICAgICAgICdzZXQgdGhlIHBvc2l0aW9uIHRvIG9uZSAoaW5jbHVkZSkgYW5kIHJlY3Vyc2UKICAgICAgICBtYUluY2x1ZGUobFBvc2l0aW9uKSA9IDEKICAgICAgICBFdmFsIGxQb3NpdGlvbiArIDEKICAgIEVsc2UKICAgICAgICAnb25jZSBsUG9zaXRpb24gZXhjZWVkcyB0aGUgbnVtYmVyIG9mIGVsZW1lbnRzIGluIHRoZSBhcnJheQogICAgICAgICdjb25jYXRlbmF0ZSBhbGwgdGhlIHN1YnN0cmluZ3MgdGhhdCBoYXZlIGEgY29ycmVzcG9uZGluZyAxCiAgICAgICAgJ2luIG1hSW5jbHVkZSBhbmQgc3RvcmUgaW4gcmVzdWx0cyBhcnJheQogICAgICAgIG1sUmVzdWx0Q291bnQgPSBtbFJlc3VsdENvdW50ICsgMQogICAgICAgIEZvciBpID0gMCBUbyBVQm91bmQobWFJbmNsdWRlKQogICAgICAgICAgICBJZiBtYUluY2x1ZGUoaSkgPSAxIFRoZW4KICAgICAgICAgICAgICAgIHNDb25jYXQgPSBzQ29uY2F0ICYgbXZBcnIoaSkgJiBTcGFjZSgxKQogICAgICAgICAgICBFbmQgSWYKICAgICAgICBOZXh0IGkKICAgICAgICBzQ29uY2F0ID0gVHJpbShzQ29uY2F0KQogICAgICAgIG1hUmVzdWx0KG1sUmVzdWx0Q291bnQpID0gc0NvbmNhdAogICAgRW5kIElmCgpFbmQgU3ViCgpFbmQgQ2xhc3M=
Visual Basic.Net Compiler version 0.0.0.5943 (Mono 3.8 - tarball)
Copyright (C) 2004-2010 Rolf Bjarne Kvinge. All rights reserved.
/home/jyrZSo/prog.vb (6,21) : error VBNC30180: Keyword does not name a type.
/home/jyrZSo/prog.vb (7,4): Compiler error around this location, the compiler hasn't implemented the error message, nor error recovery, so the compiler will probably crash soon.
at vbnc.Helper.ErrorRecoveryNotImplemented(Span Location)
at vbnc.Parser.ParseVariableDeclarator(vbnc.ParsedObject Parent, Modifiers Modifiers, vbnc.ParseAttributableInfo Info, IList result, Boolean local)
at vbnc.Parser.ParseTypeVariableDeclarator(vbnc.ParsedObject Parent, Modifiers Modifiers, vbnc.ParseAttributableInfo Info)
at vbnc.Parser.ParseTypeVariableDeclarators(vbnc.ParsedObject Parent, Modifiers Modifiers, vbnc.ParseAttributableInfo Info)
at vbnc.Parser.ParseTypeVariableMemberDeclaration(vbnc.ParsedObject Parent, vbnc.ParseAttributableInfo Info)
at vbnc.Parser.ParseTypeMembers(vbnc.TypeDeclaration Parent)
at vbnc.Parser.ParseClassDeclaration(vbnc.ParsedObject Parent, vbnc.Attributes Attributes, System.String Namespace)
at vbnc.Parser.ParseTypeDeclaration(vbnc.ParsedObject Parent, vbnc.Attributes Attributes, System.String Namespace)
at vbnc.Parser.ParseAssemblyMembers(vbnc.AssemblyDeclaration Parent, System.String RootNamespace)
at vbnc.Parser.ParseAssemblyDeclaration(System.String RootNamespace, vbnc.AssemblyDeclaration assembly)
at vbnc.Parser.Parse(System.String RootNamespace, vbnc.AssemblyDeclaration assembly)
at vbnc.Compiler.Compile_Parse()
at vbnc.Compiler.Compile()
at vbnc.Compiler.Compile(System.String[] CommandLine)
at vbnc.Main.Main(System.String[] CmdArgs)
/home/jyrZSo/prog.vb (30,44) : error VBNC90019: Expected ')'.
/home/jyrZSo/prog.vb (30,44): Compiler error around this location, the compiler hasn't implemented the error message, nor error recovery, so the compiler will probably crash soon.
at vbnc.Helper.ErrorRecoveryNotImplemented(Span Location)
at vbnc.Parser.ParseInvocationOrIndexExpression(vbnc.ParsedObject Parent, vbnc.Expression First)
at vbnc.Parser.ParseIdentifier(vbnc.ExpressionParseInfo Info)
at vbnc.Parser.ParseExponent(vbnc.ExpressionParseInfo Info)
at vbnc.Parser.ParseUnaryPlusMinus(vbnc.ExpressionParseInfo Info)
at vbnc.Parser.ParseMultDiv(vbnc.ExpressionParseInfo Info)
at vbnc.Parser.ParseIntDiv(vbnc.ExpressionParseInfo Info)
at vbnc.Parser.ParseMod(vbnc.ExpressionParseInfo Info)
at vbnc.Parser.ParsePlusMinus(vbnc.ExpressionParseInfo Info)
at vbnc.Parser.ParseConcat(vbnc.ExpressionParseInfo Info)
at vbnc.Parser.ParseBitshift(vbnc.ExpressionParseInfo Info)
at vbnc.Parser.ParseComparison(vbnc.ExpressionParseInfo Info)
at vbnc.Parser.ParseNot(vbnc.ExpressionParseInfo Info)
at vbnc.Parser.ParseAnd_AndAlso(vbnc.ExpressionParseInfo Info)
at vbnc.Parser.ParseOr_OrElse_Xor(vbnc.ExpressionParseInfo Info)
at vbnc.Parser.ParseExpression(vbnc.ParsedObject Parent)
at vbnc.Parser.ParseRedimClause(vbnc.ParsedObject Parent)
at vbnc.Parser.ParseList(vbnc.BaseList`1 List, vbnc.ParseDelegate_Parent`1 ParseMethod, vbnc.ParsedObject Parent)
at vbnc.Parser.ParseRedimClauses(vbnc.ReDimStatement Parent)
at vbnc.Parser.ParseReDimStatement(vbnc.ParsedObject Parent)
at vbnc.Parser.ParseCodeBlock(vbnc.ParsedObject Parent, Boolean IsOneLiner)
at vbnc.Parser.ParseSubDeclaration(vbnc.TypeDeclaration Parent, vbnc.ParseAttributableInfo Info)
at vbnc.Parser.ParseTypeMembers(vbnc.TypeDeclaration Parent)
at vbnc.Parser.ParseClassDeclaration(vbnc.ParsedObject Parent, vbnc.Attributes Attributes, System.String Namespace)
at vbnc.Parser.ParseTypeDeclaration(vbnc.ParsedObject Parent, vbnc.Attributes Attributes, System.String Namespace)
at vbnc.Parser.ParseAssemblyMembers(vbnc.AssemblyDeclaration Parent, System.String RootNamespace)
at vbnc.Parser.ParseAssemblyDeclaration(System.String RootNamespace, vbnc.AssemblyDeclaration assembly)
at vbnc.Parser.Parse(System.String RootNamespace, vbnc.AssemblyDeclaration assembly)
at vbnc.Compiler.Compile_Parse()
at vbnc.Compiler.Compile()
at vbnc.Compiler.Compile(System.String[] CommandLine)
at vbnc.Main.Main(System.String[] CmdArgs)
/home/jyrZSo/prog.vb (30,44) : error VBNC90019: Expected 'End'.
/home/jyrZSo/prog.vb (31,10) : error VBNC90019: Expected 'End'.
/home/jyrZSo/prog.vb (34,9) : error VBNC30203: Identifier expected.
/home/jyrZSo/prog.vb (37,8) : error VBNC30203: Identifier expected.
/home/jyrZSo/prog.vb (38,16) : error VBNC30203: Identifier expected.
/home/jyrZSo/prog.vb (39,9) : error VBNC30203: Identifier expected.
/home/jyrZSo/prog.vb (41,8) : error VBNC30203: Identifier expected.
/home/jyrZSo/prog.vb (44,4) : error VBNC30203: Identifier expected.
/home/jyrZSo/prog.vb (46,8) : error VBNC30203: Identifier expected.
/home/jyrZSo/prog.vb (47,8) : error VBNC30203: Identifier expected.
/home/jyrZSo/prog.vb (49,7) : error VBNC30203: Identifier expected.
/home/jyrZSo/prog.vb (51,18) : error VBNC30203: Identifier expected.
/home/jyrZSo/prog.vb (52,13) : error VBNC30203: Identifier expected.
/home/jyrZSo/prog.vb (55,18) : error VBNC30203: Identifier expected.
/home/jyrZSo/prog.vb (56,13) : error VBNC30203: Identifier expected.
/home/jyrZSo/prog.vb (57,9) : error VBNC30203: Identifier expected.
/home/jyrZSo/prog.vb (61,22) : error VBNC30203: Identifier expected.
/home/jyrZSo/prog.vb (62,12) : error VBNC30203: Identifier expected.
/home/jyrZSo/prog.vb (63,15) : error VBNC30203: Identifier expected.
/home/jyrZSo/prog.vb (64,24) : error VBNC30203: Identifier expected.
/home/jyrZSo/prog.vb (65,19) : error VBNC30203: Identifier expected.
/home/jyrZSo/prog.vb (66,13) : error VBNC30203: Identifier expected.
/home/jyrZSo/prog.vb (67,16) : error VBNC30203: Identifier expected.
/home/jyrZSo/prog.vb (68,17) : error VBNC30203: Identifier expected.
/home/jyrZSo/prog.vb (69,11) : error VBNC30203: Identifier expected.
/home/jyrZSo/prog.vb (71,8) : error VBNC30203: Identifier expected.
/home/jyrZSo/prog.vb (73,10) : error VBNC30203: Identifier expected.
There were 29 errors and 0 warnings.
Compilation took 00:00:00.6525530