听起来像ini
hehe吧1.txt中的"a"后加"b"
"a" to "ab" 输出到ss$Open "1.txt" For Input As #1
Do Until EOF(1) = True
Line Input #1, s$
s$=replace(s$,"a","ab")
ss$ = ss$ + s$ + vbCrLf
Loop
Close #1
hehe吧1.txt中的"a"后加"b"
"a" to "ab" 输出到ss$Open "1.txt" For Input As #1
Do Until EOF(1) = True
Line Input #1, s$
s$=replace(s$,"a","ab")
ss$ = ss$ + s$ + vbCrLf
Loop
Close #1
instr start,source$,searchPattern$
函数名instr,start为开启的位置,source$要查找的字符串,searchPattern$在什么字符串中查找。
例:foundpos%=instr(1,"is","where is my pen?")
foundpos应等于7而你只要在第九个字后输入你想要的东东
我用以下的方法,快多了。
我刚才还试来。
本来下午写过的,但当时只是做为试验,没有保存,现在只能开VB重写了。
________________________________________________________________Private Sub Form_Load()
'自已进行错误处理
Dim bTmp() As Byte
Dim bFile() As Byte
Dim lPos As Long
Dim strTmp As String
ReDim bTmp(FileLen("e:\test.dat"))
Open "e:\test.dat" For Binary As #1
Get #1, , bTmp()
strTmp = StrConv(bTmp(), vbUnicode) '转为字符串(我直接转为 vbFormUnicode不行,出错)
'转为ANSI(?),否则,如果有中文,就会不准确
lPos = InStrB(1, StrConv(strTmp, vbFromUnicode), StrConv("SuperPlayer", vbFromUnicode)) - 1
ReDim bFile(FileLen("e:\test.dat") - lPos)
Get #1, lPos, bFile() '从偏移处写入
Close #1Open "e:\file.dat" For Binary As #2
Put #2, , bFile() '写入文件
Close #2End Sub
Get #1, lPos, bFile() '从偏移处写入
->
Get #1, lPos, bFile() '从偏移处读出