here is the code.hope this helps.x=your current alphabet sequence
y=length of the current alphabet sequence
a=0
If(Right(x,1)=“Z”) Then
For i=1 To y
If(Mid(x,y-i+1,1)="Z") Then
a=a+1
Mid(x,y-i+1,1)="A"
Else
Exit For
End If
Next
If(a=y) Then
x="A"&x
Else
Mid(x,y-a,1)=Chr(Asc(Mid(x,y-a,1))+1)
End If
Else
Mid(x,y,1)=Chr(Asc(Mid(x,y,1))+1)
End If
I’ve used hexidecimal for counting, but it’s not often that is needed. I think the only advantages are to hide to the enduser what number it represents, or (in the case I mentioned) count higher with fewer digits… FF = 255 and FFF = 4095
What purpose do you have for counting, anything specific?
I am required to use that to count the number of times the document have been edited. I not sure why I must use that kinda counting style but as you know, it is not my call. haha
But i do not understand your algo, what do you mean by using hexadecimal? Coz i thought of using hexa also, but the problem will be during the transition from Z to AA and from ZZ to AAA.
The difficulty with a system which goes fro A to Z, then AA to ZZ, then AAA to ZZZ is that you are giving AAA a different value than for AA or A. In hexadecimal system you go from 0 to F, then from 10 (Note! not 00, like in you AA case) to FF, then from 100 to FFF.
If you would go from A to Z, then BA to ZZ, then BAA to ZZZ, it would be a simple icosekaihexadecimal system, where A means 0 in decimal system (see naming conventions: http://mathforum.org/dr.math/faq/faq.polygon.names.html) but digits going from A to Z, and not from 0 to Q (like in the normal hexadecimal system)
Anyway, you need a dectoalpha() and alphatodec() function, which converts a decimal number to a alphanumeric sequence, and vice versa:
Function alphatodec(s)
a=Asc("A")-1
c=1
n=0
For i=Len(s) To 1 Step -1
n=n+((Asc(Mid(s,i,1))-a)*c)
c=c*26
Next
alphatodec=n
End Function
Function dectoalpha(n)
a=Asc("A")-1
m=n
While m>=1
p=m Mod 26
If p=0 Then p=26
m=m-p
t=Chr(a+p)+t
m=m/26
Wend
dectoalpha=t