Click here to Skip to main content
15,909,503 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi.

I am using TXT000001,TXT000002,... as a primary key.

and while insert records through dataset, i need to added next number to each row.

so how can i get the next number like TXT000003,... in vb.net code?

Help would be appreciable..
Posted
Updated 18-Jun-12 1:48am
v2

1 solution

Try this[^].
 
Share this answer
 
Comments
ssd_coolguy 18-Jun-12 8:41am    
Thanks for reply..
but can please give me example.
Richard MacCutchan 18-Jun-12 8:45am    
Are you saying that you cannot figure out how to format a string containing some characters followed by a number?
ssd_coolguy 18-Jun-12 8:47am    
yes.. i tried below code.... but no output :(
intmax = String.Format(intmax, "TXT00000")
Richard MacCutchan 18-Jun-12 9:14am    
I guess you need to spend some time learning VB.NET. String.Format() creates a string of text from a format template and optional parameters. So the following line of code:
string key = String.Format("TXT{0:000000}", keyvalue)
would create the string TXT000014 if keyvalue contains the value 14.
ssd_coolguy 18-Jun-12 9:30am    
yes i will sure spend time to learn vb.net...

i got solution with below code also just check it...

intmax = nextno.ToString("TXT000000")

if intmax contians 14 then it will return TXT000014... :)Thanks..

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