VB编程:去除文本框首尾空行
程序代码
- Private Sub Command1_Click()
- Dim j As Integer
- Dim i(100) As String
- Text2 = ""
- For j = 1 To Len(Text1)
- i(j) = Mid(Text1, j, 1)
- Text2 = Text2 & i(j) & Chr(13) & Chr(10)
- Next j
-
- '去除文本框首尾空行
- If Left(Text2, 2) = Chr(13) & Chr(10) Then
- Text2 = Right(Text2, Len(Text2) - 2)
- End If
-
-
- If Right(Text2, 2) = Chr(13) & Chr(10) Then
- Text2 = Left(Text2, Len(Text2) - 2)
- End If
- End Sub
总结:
Chr(13) & Chr(10)表示回车换行