Hi,
I have to create codes with a certain algorithm.
It consists of 6 digits (positions) and looks for example like this: 6D45F3
On each position the sequence is "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F", so it has 16 possibilities.
Beginning from the last position going up to the first position the positions change according to the above sequence and starts from "0" when it has reached "F".
In the example above the next codes would be
6D45F4
6D45F5
...
6D45FF
6D4500
6D4501
...
6D450F
6D4510
...
So after each 15th loop the next positions changes and the previosu set back to "0".
I though that this should be easy but I failed with this code.
Please help me through my loops as I lost orientation
Michael
I have to create codes with a certain algorithm.
It consists of 6 digits (positions) and looks for example like this: 6D45F3
On each position the sequence is "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F", so it has 16 possibilities.
Beginning from the last position going up to the first position the positions change according to the above sequence and starts from "0" when it has reached "F".
In the example above the next codes would be
6D45F4
6D45F5
...
6D45FF
6D4500
6D4501
...
6D450F
6D4510
...
So after each 15th loop the next positions changes and the previosu set back to "0".
I though that this should be easy but I failed with this code.
Code:
var16Stelle = Array("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F") '16 Elemente
strErsterBC = UCase(InputBox("Enter the first code.", "Barcode-Generator")) 'for example 6D45F3
intRow = InputBox("Entere the number of codes to create.", "Barcode-Generator")
intStart6 = ListIndex(Mid(strErsterBC, 6, 1), var16Stelle)
intStart5 = ListIndex(Mid(strErsterBC, 5, 1), var16Stelle)
intStart4 = ListIndex(Mid(strErsterBC, 4, 1), var16Stelle)
intStart3 = ListIndex(Mid(strErsterBC, 3, 1), var16Stelle)
intStart2 = ListIndex(Mid(strErsterBC, 2, 1), var16Stelle)
intStart1 = ListIndex(Mid(strErsterBC, 1, 1), var16Stelle)
For Z = intStart6 To intRow + intStart6 - 1
If Z < 16 Then
Index6 = Z
End If
If Z = 16 + 16 * i Then 'beim ersten Durchlauf
i = i + 1
Index5 = intStart5 + i
Index6 = 0
End If
If Z = 256 + (256 * ii) Then
i = 0
i2 = i2 + 1
Index4 = intStart4 + i2
Index5 = 0
End If
If Z = 4096 + (4096 * i3) Then
i2 = 0
i3 = i3 + 1
Index3 = intStart3 + i3
Index4 = 0
End If
If Z = 65536 + (65536 * i4) Then
i3 = 0
i4 = i4 + 1
Index2 = intStart2 + i4
Index3 = 0
End If
If Z = 1048576 + (1048576 * i5) Then
i4 = 0
i5 = i5 + 1
Index1 = intStart1 + i5
Index2 = 0
End If
barcode = var16Stelle(Index1) & var16Stelle(Index2) & var16Stelle(Index3) & var16Stelle(Index4) & var16Stelle(Index5) & var16Stelle(Index6)
Please help me through my loops as I lost orientation
Michael