请教,我想替换文档中指定的一行的内容出现这样的问题:
请教,我想替换文档中指定的一行的内容,调试时,提示为无效的过程调用或参数。我是新手,现在不清楚怎么改正这个错误,请热心的朋友帮帮忙。另我想用For Next语句来实现多行指定文本的替换,请问用for循环可行吗,或着你有更好的建议吗?
下面的压缩文件就是我写的程序。
谢谢Joforn!
现在的问题是我想让我的程序可以获取指定目录下任意一个文件,但除了指定的2.txt文件可以正确读取外,别的都出错,老提示找不到文件,哪个热心人可以帮我点一下
Function readline(txtpath As String, linenum As Integer) As String '¶ÁÈ¡Ö¸¶¨ÐÐ
Dim filetxt As String, x As Variant, i As Integer
filetxt = String(FileLen(txtpath), " ")
Open txtpath For Binary As 1
Get #1, , filetxt
Close 1
x = Split(filetxt, vbCrLf)
MsgBox "¸ÃÎļþÒ»¹² " & UBound(x) + 1 & " ÐÐ" '·µ»ØÐÐÊý
If linenum > UBound(x) Then MsgBox "ÐÐÒç³ö", 64, "err!": Exit Function
If linenum <= UBound(x) Then readline = x(linenum - 1)
Set x = Nothing
End Function
Private Sub Command1_Click()
MsgBox readline("D:\.TXT", 50) 'µÚ50ÐÐÄÚÈÝ
End Sub
Private Sub Dir1_Change()
File1.Path = Dir1.Path
End Sub
Private Sub Drive1_Change()
Dir1.Path = Drive1.Drive
End Sub