本文介绍了自动递增字母数字值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好朋友,

我有字母数字值,没有次数要添加计数.如何使用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.

推荐答案

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;
        }



这篇关于自动递增字母数字值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-12 08:35