08/03/15 13:16:22 IXq0FDlx0
>>40-41 の応用でn進数の連番
コメントを下から4箇所外せば桁数固定
Function Proc(names)
ReDim rtn(UBound(names)+1)
' tbl = Array("0","1") '2進数
' tbl = Array("0","1","2","3","4","5","6","7") '8進数
tbl = Array("0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F") '16進数
n = UBound(tbl) + 1
i = 1
' w = 4 '桁数指定
' c = String(w-1,tbl(0))
For Each name In names
j = i Mod n
If j = 0 Then
c = ""
k = i
Do While k >= n
k = k \ n
c = tbl(k Mod n) & c
Loop
' l = Len(c) + 1
' If l < w Then c = String(w-l,tbl(0)) & c
End If
rtn(i-1) = name & c & tbl(j)
i = i + 1
Next
Proc = rtn
End Function