VB Script For Excel

smoochy boys on tour

DevilsKnight

I
VIP
Aug 1, 2004
1,612
46
195
Hello Guys,

I'm having a bit of trouble working out how to do something in VB Script, im using it in excel.

Basically, I need to be able to add numbers to letters and then count up. I'm using it to generate user id's

For example,

Each user ID must start with LTS and then two letters and then two numbers. So the first ID's would be:
LTSAA01, LTSAA02, LTSAA03 and so on. Once it gets to 99 it would then change to AB and so on.

Basically I'm calling on this from another form, so rather than the user have to type the ID in, it is already filled in and then the next time a user goes to add another ID it would be generated from the previous but +1

Does this make sense?

Thanks

Dk
 

XxEvilDxX

Banned
Banned
Dedicated Member
Apr 10, 2010
158
15
85
USA
Hello I think the solution here is to create a char array instead of a string. This way LTSAA01 is a array of 7 characters.
L = 0
T = 1
S = 2
A = 3
A = 4
0 = 5
1 = 6

Therefore you could find the index number 6 in the array to count in the ones column and when it reaches the tens column change the index 5 and 6 For example if index equals 6 and the value is 9, index 6 becomes 0 and index 5 becomes 1.
once you reach you max number value you can change your letter values in the same way.

Example link

This link is not exactly the way you wanted it, but it should help you to understand how it works.
If you still need help write me a message.

More about char
 
Last edited: