Dear friends,
I want to generate a unique number which increments for ex 123 with a combination of characters like for ex KN123 where only the digits should increment for ex the next unique number should be KN124 like that.. And at form load and after entry for that unique number and for the next entry it should show the next unique number .. how do i do that please tell me...
Thanks in advance.
Loading
Vilas GitePosted May 31, 2011, 6:23 AM
Are you done it or not yet?
Mayur GujrathiPosted May 30, 2011, 7:03 AM
DECLARE
@ALPHA_VAL CHAR(1) , @INT_VAL VARCHAR(1000)
DECLARE @VAL INT =97, @VAL1 INT =1
WHILE @VAL <= 122
BEGIN
SET @VAL1=1
WHILE @VAL1 < 1000
BEGIN
SET @ALPHA_VAL = CHAR(@VAL)
SET @INT_VAL = CONVERT(CHAR,@VAL1)
SET @INT_VAL= @ALPHA_VAL + @INT_VAL
PRINT @INT_VAL
SET @VAL1 =@VAL1+1
END
SET
@VAL=@VAL+1
END
Vilas GitePosted May 30, 2011, 5:45 AM
Kavita BPosted May 30, 2011, 5:41 AM
Thanks
I do not have word 2007 so not able to open ur .docx file... Can u give it in .doc format?
VulpesPosted May 30, 2011, 5:40 AM
class Form1 : Form // EDITED
{
private static string lastNumber = "KN123";
private string currentNumber;
public Form1()
{
InitializeComponent();
int index = lastNumber.IndexOfAny("0123456789".ToCharArray());
int last = int.Parse(lastNumber.Substring(index));
lastNumber = lastNumber.Substring(0, index) + (last + 1).ToString();
currentNumber = lastNumber;
}
// rest of Form1 code
}
If you want to keep track of instances created duing multiple runnings of your application, then you will need to save lastNumber to disk at the end of each running and then reload it at the start of the next running.
Vilas GitePosted May 30, 2011, 5:35 AM
please check this... this is fulfill your requirment