zl程序教程

您现在的位置是:首页 >  后端

当前栏目

VB编程:去除文本框首尾空行-51

编程 去除 vb 51 文本框 空行
2023-09-14 09:07:16 时间

image

程序代码

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)表示回车换行