VB删除重复行时把空行也一并删除了。。。。

我的代码如下:Open"a.txt"ForInputAs#1Open"b.txt"ForOutputAs#2DimSAsStringDimCAsNewCollection... 我的代码如下:
Open "a.txt" For Input As #1
Open "b.txt" For Output As #2
Dim S As String
Dim C As New Collection
Dim V As Variant
On Error Resume Next
Do Until EOF(1)
Input #1, S
Call C.Add(S, S)
Loop
For Each V In C
Print #2, V
Next
Close #1, #2

每次运行时可以把重复的行删除掉,但是空行也一并删掉了。。。。
空行是为了便于阅读而加入的,怎么才能让它不删除空行呢?
谢谢各位了。
展开
 我来答
最美乡村行
2011-10-15 · TA获得超过1137个赞
知道大有可为答主
回答量:1191
采纳率:0%
帮助的人:1740万
展开全部
这样试一试

我测试通过

Private Sub Form_Load()
Open App.Path & "\a.txt" For Input As #1
Open App.Path & "\b.txt" For Output As #2
Dim S As String
Dim C As New Collection
Dim V As Variant
On Error Resume Next
i = 0
Do Until EOF(1)
Input #1, S
If Trim(S) = "" Then

Call C.Add(S, S & i)
i = i + 1
Else
Call C.Add(S, S)
End If
Loop
For Each V In C
Print #2, V
Next
Close #1, #2

End Sub
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式