有时候一个,有时候不只1个. 富文本框
网上代码都不行.
要把光标移到有文字的最后一行尾处.
不行.
Private Sub Command1_Click()
If Right(Text1.Text, 2) = vbCrLf Then Text1.Text = Left(Text1.Text, Len(Text1.Text) - 1)
End Sub
Function myTrim(ByVal s As String) As String'''这函数也不行老报错
Dim Length As Long
Dim Char As String
If s <> "" Then
s = Trim(s)
Length = Len(s) + 1
Do
Length = Length - 1
Char = Mid(s, Length, 1)''这里老报错
Loop Until Char <> vbCr And Char <> vbLf
myTrim = Mid(s, 1, Length)
End If
End Function
1、打开Visual Basic 6.0软件,新建一个标准exe工程,窗体设计界面上添加一个Text1,一个Command控件;
2、设计Text1的Multiline属性值为True;
3、窗体上进入代码编辑界面,代码如下:
Private Sub Command1_Click()4、单击运行按钮或者按下F5,运行工程;
点击按钮前后发现最后一行空行被删除了:
vb 如何删除文本框最后一行空行?
1、打开Visual Basic 6.0软件,新建一个标准exe工程,窗体设计界面上添加一个Text1,一个Command控件;2、设计Text1的Multiline属性值为True;3、窗体上进入代码编辑界面,代码如下:Private Sub Command1_Click()If Right(Text1.Text, 2) = vbCrLf Then Text1.Text = Left(Text1.Text, Len(Text1...
vb 怎么删除文本框最后一行空行?
建Text1, 改Multiline=True,再建Command1.代码如下。=== Private Sub Command1_Click()If Right(Text1.Text, 2) = vbCrLf Then Text1.Text = Left(Text1.Text, Len(Text1.Text) - 1)End Sub
用VB删除txt文件最后一行
'首行空行,是InStr(s, vbCrLf)=1 '末行空行,是InStrRev(s, vbCrLf)=Len(s)-1 '其他行出现空行,是InStr(s, vbCrLf & vbCrLf)>0 Private Sub Command1_Click()Dim s As String, b As Boolean s = Text1 Do Until InStr(s, vbCrLf & vbCrLf) = 0 s = Replace(s, vbCrLf & vbCrL...
用vb如何如何自动清除文本文件中的空行?
Private Sub Command1_Click()Dim tx() As String, tmp As String, n As Integer '首先将txt文件里面非空行的内容读进数组tx里 Open "d:\\a.txt" For Input As #1 n = 0 Do While Not EOF(1)Line Input #1, tmp If tmp <> "" Then ReDim Preserve tx(n)tx(n) = tmp n = n ...
vb怎样在文本文件每个段落间空一行?
Private Sub Command1_Click()'把txt载入到文本框或者变量中 Text1.Text = Replace(Text1.Text, vbCrLf, vbCrLf & vbCrLf)'输出文本框或者变量即可 End Sub
VB 如何删除文本框第一行的空行?
Text1.Text = Replace(Text1.Text, " " + vbCrLf, vbCrLf) '清除换行符前的空格。Loop Text1.Text = Replace(Text1.Text, vbCrLf + vbCrLf, vbCrLf) '清除行与行之间的空行。If InStr(Text1.Text, vbCrLf) = 1 Then Text1.Text = Replace(Text1.Text, vbCrLf, "", 1, 1)'清除为首...
vb如何删除某一行,如第一行或者空行
Dim s As String Open "31029600.txt" For Input As #1 Open "31029600_1.txt" For Output As #2 Do Until EOF(1)Line Input #1, s If Val(s) <> 0 Then Print #2, s Loop Close #2 Close #1
vb 删除指定的txt中的内容-疑惑
这样开头就不会出现空行了 End IfLoopText1.Text = qeClose #1End SubPrivate Sub Command1_Click()Dim st() As StringDim qe As StringDim i As Integerst = Split(Text1.Text, vbCrLf) '文本框内容按回车符分割为数组For i = UBound(st) To 0 Step -1 '数组从后往前遍历 If...
VB 如何判断文本框首行为空?
用split重新解离一次回车符(\\r\\n),把空行都去掉(c#代码):string[] ss=textBox1.Text.Split('\\r\\n');textBox.Text="";foreach(string s in ss){ if(s.Trim()!=""){ textBox.Text += s + "\\r\\n";} }
VB 如何在多行文本框的每一行下面插入几行空行?
空行 函数是VbCrlf text1 = "123" & vbcrlf & vbcrlf & "456"123和456之间就间隔两行