请问怎样可以用vb修改文档特定行的内容呢,我只会编打开保存文档的vb程序,中间部分的不会。请高手关注,谢了

meizhouhu 2008-03-07 09:21:15
/JOB
//NAME 1A1A
//POS
///NPOS 2,0,0,0,0,0
///TOOL 0
///POSTYPE PULSE
///PULSE
C0000=4999,521,-294,1333,-204,1400
C0001=-299,86505,-8831,4032,56636,1038
//INST
///DATE 2008/03/06 10:34
///ATTR SC,RW
///GROUP1 RB1
NOP
MOVL C0000 V=23.0
MOVL C0001 V=83.3
END
以上是一个文档的内容,如果想把第八,九行
C0000=4999,521,-294,1333,-204,1400
C0001=-299,86505,-8831,4032,56636,1038
数据修改为
C0000=4000,621,-294,1333,-204,1400
C0001=799,76505,-8831,4032,56636,1038

vb程序应该怎样编。
自己已经编了怎样打开文件,保存,但中间部分不会,请高手赐教。

...全文
33 点赞 收藏 5
写回复
5 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
meizhouhu 2008-03-09
刚才试了下,程序很好用,再次感谢热心人。
回复
meizhouhu 2008-03-09
恩,我试一下,谢谢JENNYVONUS
回复
Option Explicit

Private Sub Command1_Click()
Dim s As String
Open "d:\1.txt" For Input As #1
Open "d:\2.txt" For Output As #2
Do
Line Input #1, s
s = Trim(s)
If 1 = InStr(1, s, "C0000") Then
s = modifysecond(s, "88888888")
End If
If 1 = InStr(1, s, "C0001") Then
s = modifysecond(s, "99999999")
End If
'Debug.Print s
Print #2, s

Loop While Not EOF(1)
Close #2
Close #1
End Sub

Private Function modifysecond(ByVal s As String, ByVal change As String) As String
Dim i As Long
Dim j As Long
i = InStr(1, s, ",")
j = InStr(i + 1, s, ",")
Dim ss As String
ss = Mid(s, 1, i) & change & Mid(s, j)
modifysecond = ss
End Function
回复
等会儿俺写一个试试。
回复
有没有规则,怎么改,光改这一次就手工改得了。
回复
相关推荐
发帖
VB基础类
创建于2007-09-28

7491

社区成员

VB 基础类
申请成为版主
帖子事件
创建了帖子
2008-03-07 09:21
社区公告
暂无公告