Hi,
would you kindly tell me why this code is not working please????
After i paste and press ALT+F8 its blank,if you can point me to hte right direction ,would much... appreciated.here is the code taken from here;
http://www.xtremevbtalk.com/showthread.php?t=168296
</pre> thanks
sezuh
would you kindly tell me why this code is not working please????
After i paste and press ALT+F8 its blank,if you can point me to hte right direction ,would much... appreciated.here is the code taken from here;
http://www.xtremevbtalk.com/showthread.php?t=168296
Code:
Option Explicit ' ' Odometer-style Combination generating functions ' by MathImagics (Dr Memory) 2004 ' ' SetCombination ' NextCombination ' ThisCombination ' Dim Cwheel() As Long Public Sub SetCombination(ByVal N As Long, ByVal K As Long, ByVal Combn As String) ReDim token(K) As String token = Split(Combn, ",") If UBound(token) <> K - 1 Then Exit Sub Dim W As Long ReDim Cwheel(0 To K) For W = 1 To K Cwheel(W) = Val(token(W - 1)) If Cwheel(W) <= Cwheel(W - 1) Then Exit Sub ' invalid combn If Cwheel(W) > N Then Exit Sub ' ditto Next End Sub Public Function ThisCombination() As String ' ' Current Combination readout ' Dim i As Long, Comb As String Comb = Cwheel(1) For i = 2 To UBound(Cwheel) Comb = Comb & ", " & Cwheel(i) Next ThisCombination = Comb End Function Public Sub NextCombination(ByVal N As Long, ByVal K As Long) ' "Combination Odometer" ' ' By MathImagics: the array Cwheel contains the current ' K items combined, in increasing order. ' Each call to this sub will adjust Cwheel ' so it contains ' the NEXT combination in lex order ' Dim i As Long Dim j As Long i = K While Cwheel(i) >= N - K + i i = i - 1 ' find rightmost wheel that allows an increment If i = 0 Then ' wraps around (natch!) i = 1 Cwheel(1) = 0 End If Wend Cwheel(i) = Cwheel(i) + 1 For j = i + 1 To K Cwheel(j) = Cwheel(i) + j - i Next End Sub
</pre> thanks
sezuh
Last edited: