auto generate code number
-
OH.. this will not work if the code is deleted in between then the count and max number at end will be an issue
:wtf: I have no idea what you are talking about. :wtf:
I know the language. I've read a book. - _Madmatt
-
i was trying to do something like this as well.. stuck with how to pass a string as seperator in split function..!! frustrating syntax error
FEMDEV wrote:
stuck with how to pass a string as seperator in split function.
It may not be necessary to do this. According to the MSDN documentation for Int32.TryParse()[^]
When this method returns, contains the 32-bit signed integer value equivalent to the number contained in s, if the conversion succeeded, or zero if the conversion failed. The conversion fails if the s parameter is null, is not of the correct format, or represents a number less than MinValue or greater than MaxValue. This parameter is passed uninitialized.
. I didn't think that it worked like that, however, it says that it does. From the
int
returned you will know how many characters to use in aString.Replace()
call to insert the new value.Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”
-
FEMDEV wrote:
stuck with how to pass a string as seperator in split function.
It may not be necessary to do this. According to the MSDN documentation for Int32.TryParse()[^]
When this method returns, contains the 32-bit signed integer value equivalent to the number contained in s, if the conversion succeeded, or zero if the conversion failed. The conversion fails if the s parameter is null, is not of the correct format, or represents a number less than MinValue or greater than MaxValue. This parameter is passed uninitialized.
. I didn't think that it worked like that, however, it says that it does. From the
int
returned you will know how many characters to use in aString.Replace()
call to insert the new value.Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”
Sorry Henry, it does not work as the text seems to suggest. The string has to contain a number, nothing but a number, that is.
int.Parse("123abc")
does throw a FormatException,int.TryParse("123abc", out i)
does return false. ditto for "abc123". :)Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
-
i was trying to do something like this as well.. stuck with how to pass a string as seperator in split function..!! frustrating syntax error
Use a regex: "(?[a-zA-Z]+)(?\d*)" splits it into the Name and any number.
private Regex splitNameAndNumber = new Regex(
"(?[a-zA-Z]+)(?\\d*)",
RegexOptions.ExplicitCapture
| RegexOptions.IgnorePatternWhitespace
| RegexOptions.Compiled
);I have learnt that you can not make someone love you, all you can do is stalk them and hope they panic and give in. Apathy Error: Don't bother striking any key.
-
Sorry Henry, it does not work as the text seems to suggest. The string has to contain a number, nothing but a number, that is.
int.Parse("123abc")
does throw a FormatException,int.TryParse("123abc", out i)
does return false. ditto for "abc123". :)Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
I thought that was how it worked. Couldn't test it as the machine I'm using at the moment doesn't have VS on it.
Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”
-
Use a regex: "(?[a-zA-Z]+)(?\d*)" splits it into the Name and any number.
private Regex splitNameAndNumber = new Regex(
"(?[a-zA-Z]+)(?\\d*)",
RegexOptions.ExplicitCapture
| RegexOptions.IgnorePatternWhitespace
| RegexOptions.Compiled
);I have learnt that you can not make someone love you, all you can do is stalk them and hope they panic and give in. Apathy Error: Don't bother striking any key.
or use a new separator such as '#', or a fixed number of digits, or just locate the first digit using IndexOfAny(), or... :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
-
or use a new separator such as '#', or a fixed number of digits, or just locate the first digit using IndexOfAny(), or... :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
You can tell .NET is a Microsoft product - a dozen different ways to do the same thing (none of them that obvious when you are getting started!) It took me ages to work out how to format a floppy in Win95, then I found about six in as many minutes...
I have learnt that you can not make someone love you, all you can do is stalk them and hope they panic and give in. Apathy Error: Don't bother striking any key.
-
I thought that was how it worked. Couldn't test it as the machine I'm using at the moment doesn't have VS on it.
Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”
VS is the first thing I install on any PC I touch! And do you really need VS to test a single method? Notepad.exe + csc.exe are a mighty pair. :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
-
VS is the first thing I install on any PC I touch! And do you really need VS to test a single method? Notepad.exe + csc.exe are a mighty pair. :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
Shhhh! It's not my PC.
Luc Pattyn wrote:
Notepad.exe + csc.exe are a mighty pair
If both were on this thing (and if I'd thought of it, which is doubtful) I might have. :)
Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”
-
Shhhh! It's not my PC.
Luc Pattyn wrote:
Notepad.exe + csc.exe are a mighty pair
If both were on this thing (and if I'd thought of it, which is doubtful) I might have. :)
Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”
Notepad should be there, unless it got removed. csc.exe is part of .NET, of which some versions are always present on Vista/Win7 AFAIK. :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
-
i tried to put the string of the latest code in an array and parse it for int. put the integers in a integer array. then convert them to form a string of int values and add 1 to this string converted to int. but i couldn't split the initial string!!! what should be the split criteria? string would be always of form fname.lnamexxx where x could be any number 1, 99,999,9999 anything. don't need anyone to write a code just an immediate help, if possible for split criteria of the initial string[fname.lnamexx] .
Why don't you just have a identity column in your table. At that point, how many instances of a name (or any column value for that matter) you have is inconsequential...
.45 ACP - because shooting twice is just silly
-----
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
-----
"The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001 -
i was trying to do something like this as well.. stuck with how to pass a string as seperator in split function..!! frustrating syntax error
Lyuc is right in saying that's pretty much you're last option. But, what he didn't say is that this method will also get slower and slower as you add more and more ID's to scan. The solution works, but it isn't scalable. You may want to take this information back and say that "it can be done, but..."
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007, 2008
But no longer in 2009...