|
-
Aug 15th, 2020, 11:35 PM
#4
Re: Copy the last line from textbox into another textbox
 Originally Posted by peterst
Split the text by Chr(10) (line feed) and get last line:
VB.NET Code:
Dim lines() = TextBox1.Text.Split(Chr(10))
Dim lastLine = lines.Last()
Actually, that code is bad. You are splitting only on line feed characters so you are leaving the carriage returns in the results. That could cause problems if you ever need to compare Strings or in various other situations. If you were going to use Split, you should split on all possible line breaks. Using the Lines property will do that automatically.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|