摘要:[VB .NET] 不會換行的問題...
在TextBox物件中輸入時,按下Enter,所取得的換行為一個字元(ascii:13)
但輸出在某些呈現物件,它要兩個字元(ascii:13,10)
所以寫一個簡單的轉換如下...
Private Function ConvertNewLine(ByVal str As String) As String
Dim result As String = ""
Dim lst As New List(Of Char)
Dim arr = str.ToCharArray()
For index = 0 To arr.Length - 1
lst.Add(arr(index))
If AscW(arr(index)) = 13 Then
lst.Add(ChrW(10))
End If
Next
result = CStr(lst.ToArray())
Return result
End Function