Click here to Skip to main content
15,889,527 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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.
Posted

Hi Dear,

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

C#
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;
        }
 
Share this answer
 
Comments
dmunisubbu 28-Aug-12 1:47am    
Yes i tried this example,

finally i am getting the result like,
SEA999
SEA1000
SEA1001
SEA1002

it was missing the "Zeros"

Any how this example useful for me.
Thanks
Pandiarajan A 28-Aug-12 1:48am    
Dear Kishore,

Thanks for your answer. i will check.
D-Kishore 28-Aug-12 1:49am    
Thanks
Pandiarajan A 28-Aug-12 1:51am    
i faced the same problem. please look this and provide your valuable comments
Pandiarajan A 28-Aug-12 1:52am    
kishore, do you have code from VB6 and VB.net for this requirement?
 
Share this answer
 
v2
Comments
Pandiarajan A 28-Aug-12 1:50am    
Hello Prasad.

thanks for the link. sorry i don't have knowledge in C##. please give the idea from VB6
Prasad_Kulkarni 28-Aug-12 1:54am    
Please see updated answer.
Pandiarajan A 28-Aug-12 4:47am    
Many thanks Prasad
Manas Bhardwaj 28-Aug-12 8:34am    
+5

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900