自动递增字母数字值

自动递增字母数字值

问题描述:

你好朋友,

我有字母数字值,没有次数要添加计数.如何使用VB6进行编码

例如:

字母数字值:SEA0000998
添加次数:5

结果如下

SEA0000998
SEA0000999
SEA0001000
SEA0001001
SEA0001002

请帮助任何人.

Hello Friends,

i have alphanumeric value and no of times to add count. how to code using VB6

for example:

alphanumeric value: SEA0000998
no of times to add: 5

the result comes as follows

SEA0000998
SEA0000999
SEA0001000
SEA0001001
SEA0001002

please help anyone.

亲爱的,

在这里,我在用C#给出代码.这将对您有所帮助.

Hi Dear,

Here i am giving the code in c#. It will be helpfull for you.

private void Form3_Load(object sender, EventArgs e)
        {
            var strid = "SEA0000998";
            var intPos = strid.Length;
            var stringChars = new string[4];
            var intSummand = 1;

            for (int i = strid.Length - 1; i >= 0; i--)
            {
                var charTmp = strid.Substring(i, 1).ToCharArray()[0];
                if (char.IsNumber(charTmp))
                {
                    // set the position one element back
                    intPos--;
                }
                else
                {
                    // we found a char and so we can break up
                    break;
                }
            }
            var numberString = string.Empty;

            if (intPos < strid.Length)
            {
                numberString = strid.Substring(intPos, strid.Length - intPos);
            }
            for (int i = 0; i < stringChars.Length; i++)
            {
                strid = strid.Substring(0, strid.Length - numberString.Length);

                strid += (int.Parse(numberString) + intSummand).ToString();

                numberString = (int.Parse(numberString) + intSummand).ToString();

                stringChars[i] = strid.ToString();
            }

            var finalString = stringChars;
        }


参考:
自动生成字母数字唯一键 [自动递增alpha数字 [带有字母数字的自动递增数字 [ ^ ]
字母数字自动编号 [自动增量字母数字 [
Refer:
Auto generate a alphanumeric uniquekey[^]



Automatic Increment alpha numeric[^]
Auto increment number with alpha numeric[^]
alphanumeric autonumber[^]
Automatic Increment alpha numeric[^]