 |
|
|
 |
|
 |
I just would like to contribute this code of mine regarding increment of alphanumeric. All you have to do is create a class and paste this. Then, it's up to you on how to pass a value. You can pass a value of alphanumeric providing that the last character is a number. You this will help you.
by Manuel A. Rivas Jr.
email: marj20ph@yahoo.com
public string pAutoNoResult(string strNumber)
{
int intcounter = 1;
int inttrynumber = 0;
string strtext = "";
string strresult = "";
while (strNumber.Length + 1 > intcounter)
{
if (int.TryParse(strNumber.Substring(strNumber.Length - intcounter, intcounter), out inttrynumber) == true)
{
strtext = strNumber.Substring(strNumber.Length - intcounter, intcounter);
}
else
{
strtext = Convert.ToString(Convert.ToInt64(strtext) + 1);
return strresult = strNumber.Substring(0, strNumber.Length - strtext.Length) + strtext;
}
intcounter++;
}
strtext = Convert.ToString(Convert.ToDouble(strtext) + 1);
return strresult = strNumber.Substring(0, strNumber.Length - strtext.Length) + strtext;
}
|
|
|
|
 |
|
|
 |
|
 |
Thanks, articles like this are why I love CP.
|
|
|
|
 |
|
 |
I have a SQL version
declare @index int,@curstring varchar(10),@hasstuff int, @tempstr varchar(1)
set @curstring = UPPER('tests')
set @hasstuff = 1
set @index = len(@curstring)
while @hasstuff=1 and @index>0
begin
set @hasstuff = 0
set @tempstr = substring(@curstring,@index,1)
if ascii(@tempstr)=57
begin
set @tempstr=CHAR(65)
end
else if ascii(@tempstr)=90
begin
set @tempstr=CHAR(48)
set @hasstuff = 1
end
else
begin
set @tempstr=CHAR(ascii(@tempstr)+1)
end
set @curstring = STUFF(@curstring,@index,1,@tempstr)
set @index =@index - 1
end
select @curstring
|
|
|
|
 |
|
 |
Can i ask that what is mean by isAllZed and isAllNine in the program?
Thanks.
|
|
|
|
 |
|
 |
Next to Z9 is ZA, that's correct, but next to Z99 is A00 while it should be Z9A, shouldn't it?
Also, with only one digit, next to Z is A, while it should be 0 (doesn't use numbers after reaching Z anymore). Or am I worng? (worng? lol, that's wrong)
|
|
|
|
 |
|
 |
Hi All,
i want to generate a unique primary key, something similar to the auto increment feature, but i do not want it to be auto increment.
The reasoning for this is: this table will have rows deleted by the hundreds every day, and maybe even thousands in a few years (I hope!), All the while having more rows replace the ones that were erased. Is there a way to have mysql create a unique key that is just randomly generated?
Thanks in advance!
|
|
|
|
 |
|
 |
This code is just amazing thank u BOSS:
|
|
|
|
 |
|
 |
Nothing about alphanumeric incrementing...
|
|
|
|
 |
|
 |
Next value for PRO01A9 is PRO01B0, not the PRO01B1
|
|
|
|
 |
|
 |
Actually it should be PRO01BA, but it depends on the definition of the number set. My assumption is based on using the U.S. alphabet in its common order (uppercase only) and the digits in their numerical value (A-Z0-9). Whether digits are before letters do not matter (0-9A-Z), as the rollover would always be A. This definition is called base 36 and I have used it for years.
You would be correct if the set is A-Z1-90, which has the drawback of making the value very difficult to sort.
|
|
|
|
 |