Dim str As String = "Test" & vbCrLf str = str.Substring(0, str.Length - vbCrLf.Length)
same with Environment.NewLine instead of vbCrlf:
str = "Test" & Environment.NewLine str = str.Substring(0, str.Length - Environment.NewLine.Length)
Btw, the difference is this: Environment.NewLine is platform-specific (fe returns another line in another OS)
Your remove -approach does not work because you did not assign the return value of this function to the original string link:
str = str.Remove(str.Length - Environment.NewLine.Length)
or if you want to replace all NewLines:
str = str.Replace(Environment.NewLine, String.Empty)
Tim schmelter
source share