vb 替换txt文本文件中的指定字符串 5
例如:1,2,3,4,5,613,24,3,4,2,70,2,3,98,45,6a,b,c,d,e,f将每行的第一个“,”替换为“,1,”达到目的为:1,1,2,3,4,...
例如:1,2,3,4,5,6
13,24,3,4,2,7
0,2,3,98,45,6
a,b,c,d,e,f
将每行的第一个“,”替换为“,1,”
达到目的为:
1,1,2,3,4,5,6
13,1,24,3,4,2,7
0,1,2,3,98,45,6
a,1,b,c,d,e,f 展开
13,24,3,4,2,7
0,2,3,98,45,6
a,b,c,d,e,f
将每行的第一个“,”替换为“,1,”
达到目的为:
1,1,2,3,4,5,6
13,1,24,3,4,2,7
0,1,2,3,98,45,6
a,1,b,c,d,e,f 展开
1个回答
展开全部
Private Sub Form_Load()
Dim Ar, I As Long, S As String
Open "d:\123.txt" For Binary As #1
S = StrConv(InputB(LOF(1), 1), vbUnicode)
Close #1
Ar = Split(S, vbCrLf)
For I = 0 To UBound(Ar)
Ar(I) = Replace(Ar(I), ",", ",1,", , 1)
Next
Open "D:\123.TXT" For Output As #1
Print #1, Join(Ar, vbCrLf)
Close #1
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询