Text break into two part
-
hi, i am beginner in c#, i need tour help, i want two break textbox text in two part For example textbox1.text = "ABT-001" ABT-001 break into "ABT-00" and "1" textbox2.text = "ABT-00" and textbox3.text="1" Hope you understand by question Thanks
You are looking for the String.Substring method[^] What it does it returns a new string, cut down from the original. You just have to specify the start position of the new string (in characters from the beginning of the original) and the length of the new string, in characters:
int len = textBox1.Text.Length;
textbox2.Text = textBox1.Text.Substring(0, len - 1);
textbox3.text = textbox1.Text.Substring(len - 1);(if you don't specify the length, you get the whole remaining string).
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
-
hi, i am beginner in c#, i need tour help, i want two break textbox text in two part For example textbox1.text = "ABT-001" ABT-001 break into "ABT-00" and "1" textbox2.text = "ABT-00" and textbox3.text="1" Hope you understand by question Thanks
Why would anyone vote you down for that? Beginners have to start somewhere, and English isn't everybody's native language. Compensated.
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
-
Why would anyone vote you down for that? Beginners have to start somewhere, and English isn't everybody's native language. Compensated.
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
OriginalGriff wrote:
Why would anyone vote you down for that?
A trend that seems to be increasingly common. There are obviously a (I hope small) number of people whose only contribution to CodeProject is to down vote those questions they deem unworthy. I guess in a population this size there will always be a percentage of morons.
I must get a clever new signature for 2011.
-
OriginalGriff wrote:
Why would anyone vote you down for that?
A trend that seems to be increasingly common. There are obviously a (I hope small) number of people whose only contribution to CodeProject is to down vote those questions they deem unworthy. I guess in a population this size there will always be a percentage of morons.
I must get a clever new signature for 2011.
Richard MacCutchan wrote:
morons.
I can think of another word which fits them better. Starts with "A"... :laugh:
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
-
Richard MacCutchan wrote:
morons.
I can think of another word which fits them better. Starts with "A"... :laugh:
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
Assets ? :-D
I know the language. I've read a book. - _Madmatt Two letters away from being an asset
-
Assets ? :-D
I know the language. I've read a book. - _Madmatt Two letters away from being an asset
Close enough! :laugh:
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
-
hi, i am beginner in c#, i need tour help, i want two break textbox text in two part For example textbox1.text = "ABT-001" ABT-001 break into "ABT-00" and "1" textbox2.text = "ABT-00" and textbox3.text="1" Hope you understand by question Thanks
What pattern do you want to use to break the text apart? Do you want to break it based on the length? Is it based on a particular string pattern, e.g. XXX-NN representing the first part? Before anybody can offer you a definitive answer, you need to explain the problem fully.
I'm not a stalker, I just know things. Oh by the way, you're out of milk.
Forgive your enemies - it messes with their heads
-
Why would anyone vote you down for that? Beginners have to start somewhere, and English isn't everybody's native language. Compensated.
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
Amazing - you got downvoted! Compensated.
The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it. My latest tip/trick
-
Amazing - you got downvoted! Compensated.
The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it. My latest tip/trick
Now, I wonder who did that? :laugh: Was it an As...
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
-
hi, i am beginner in c#, i need tour help, i want two break textbox text in two part For example textbox1.text = "ABT-001" ABT-001 break into "ABT-00" and "1" textbox2.text = "ABT-00" and textbox3.text="1" Hope you understand by question Thanks
Hi, Without knowing exactly what criteria you want to use to split the string it is a bit difficult to give a definite answer. Something you could look at and that is really powerful is Regular Expressions (RegEx) Here are a few samples found using google: http://msdn.microsoft.com/en-us/library/8yttk7sy.aspx[^] http://www.codeproject.com/Answers/147947/How-to-split-string-to-two-text-boxes.aspx#answer2[^] Hope it helps. Valery.