VB如何修改TXT文件指定行的指定内容
举个例子,C盘中的WWE.txt内容如下:"CHAMPION=EDGE"CHAMPION=EDGE我想把第2行的EDGE改为UNDERTAKER如何写代码?注:不要用整行...
举个例子,C盘中的WWE.txt内容如下:
"CHAMPION=EDGE
"CHAMPION=EDGE
我想把第2行的EDGE改为UNDERTAKER
如何写代码?
注:不要用整行替换的方法,请按以下思路:
1.定位到第2行
2.搜索该行的EDGE
3.将其替换为UNDERTAKER 展开
"CHAMPION=EDGE
"CHAMPION=EDGE
我想把第2行的EDGE改为UNDERTAKER
如何写代码?
注:不要用整行替换的方法,请按以下思路:
1.定位到第2行
2.搜索该行的EDGE
3.将其替换为UNDERTAKER 展开
3个回答
展开全部
i can do it for you
Private Sub Command1_Click()
Dim str(10000) As String
f$ = "c:\WWE.txt"
Open f For Input As #1
For i = 0 To 10000
If Not EOF(1) Then Input #1, str(i): MsgBox str(i) Else MsgBox i: Exit For
Next
Close
Dim a() As String
a = Split(str(1), "=")
a(1) = "UNDERTAKER"
str(1) = a(0) + "=" + a(1)
MsgBox str(1)
Open f For Output As #1
For j = 0 To i - 1: Print #1, """" + str(j): Next
Close #1
End Sub
Private Sub Form_Load()
Command1.Caption = "Modify Row 2"
End Sub
Private Sub Command1_Click()
Dim str(10000) As String
f$ = "c:\WWE.txt"
Open f For Input As #1
For i = 0 To 10000
If Not EOF(1) Then Input #1, str(i): MsgBox str(i) Else MsgBox i: Exit For
Next
Close
Dim a() As String
a = Split(str(1), "=")
a(1) = "UNDERTAKER"
str(1) = a(0) + "=" + a(1)
MsgBox str(1)
Open f For Output As #1
For j = 0 To i - 1: Print #1, """" + str(j): Next
Close #1
End Sub
Private Sub Form_Load()
Command1.Caption = "Modify Row 2"
End Sub
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
用like 找到第2个 place替换
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询