how to remove the first line of textbox and add it to other textbox?
how to remove the first line of textbox and add it to other textbox?
Code:TextBox2.Text = TextBox1.Lines(0) 'copied the first line Dim b As String() = Split(TextBox1.Text, vbNewLine), splits the text into lines TextBox1.Text = String.Join(vbNewLine, b, 1, b.Length - 2) ' joins them together again, ignoring the first line
A fun card game written in VBA within Excel Tri Peaks
First of all, everyone who posts a question here needs help, so your thread title is all but useless. The title is supposed to help us determine which threads are relevant to us without having to waste our time opening every single one. Sometimes, if the title doesn't tell me anything then I just ignore the thread. Do you want people ignoring your thread? Please provide a title that describes the topic of the thread.
As for the question, you should work with the Lines property of the TextBox, which allows you to get or set the contents of the control as a String array containing one element per line. You can get the Lines property and get the first line from the first element. You can then copy all but the first line to a new array, which can be done in several ways. One way would be to create a List(Of String) from the array, Remove the first item and then create a new array from the List. You can then assign the new array back to the Lines property. As for adding the line to another TextBox, you could use the AppendText method or just the concatenation operator (&), or you could work with the Lines property again.
2007-2013
Why is my data not saved to my database? | Communicating between multiple forms | MSDN Data Walkthroughs
MSDN "How Do I?" Videos: VB | C#
VBForums Database Development FAQ
My CodeBank Submissions: VB (*NEW* Pausing Code) | C#
My Blog: Using Parameters in ADO.NET | Keyboard Events | Assemblies & Namespaces
vb.net Code:
Dim transfer As String = TextBox1.Lines(0) TextBox1.Text = TextBox1.Text.Substring(transfer.Length + 1) TextBox2.AppendText(vbCrLf & transfer) 'adds at end '------- OR ------- TextBox2.Text = transfer & vbCrLf & TextBox2.Text 'adds at start
As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"
Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!