VB师长你的了!!请
发布网友
发布时间:2024-10-10 09:44
我来回答
共2个回答
热心网友
时间:2024-11-16 07:09
很容易去掉其中的空格行:
首先去掉空格:A = Replace(A, " ", "")
这时候就会有两个相邻的空行,那就去掉空行:
A = Replace(A, vbNewLine & vbNewLine & vbNewLine, vbNewLine)
A = Replace(A, vbNewLine & vbNewLine, vbNewLine)
OK,大功告成了!
如果还想去掉末尾的回车,那也很容易啊!
这样:
If Right(A, 2) = vbNewLine Then A = Left(A, Len(A) - 2)
OK,末尾没有回车了!
完整代码如下:
Private Sub Command1_Click()
Dim A As String
Dim B As String
Open "d:\排列三1.txt" For Input As #1
Do While Not EOF(1)
Line Input #1, B
A = A & B & vbCrLf
Loop
Close
Open "d:\排列三2.txt" For Input As #1
Do While Not EOF(1)
Line Input #1, B
A = A & B & vbCrLf
Loop
Close
'这里是去掉空格行
A = Replace(A, " ", "")
A = Replace(A, vbNewLine & vbNewLine, vbNewLine)
'这里是去掉末尾的回车
If Right(A, 2) = vbNewLine Then A = Left(A, Len(A) - 2)
Open "d:\排列三合并.txt" For Output As #1
Print #1, A
Close
End Sub
热心网友
时间:2024-11-16 07:10
Private Sub Command1_Click()
Dim T As String
Dim T1 As String
Open "D:\数集1.txt" For Input As #1
T = StrConv(InputB(LOF(1), 1), vbUnicode)
Close #1
Open "D:\数集2.txt" For Input As #1
While Not EOF(1)
Line Input #1, T1
T = Replace(T, T1 & vbCrLf, "")
Wend
Close #1
Open "D:\数集1减去数集2的差集.txt" For Output As #1
Print #1, T
Close #1
MsgBox "完毕"
End Sub
只需添加一个line 按行读入即可