Private Sub 换第2行() Dim cc() As String,cTS As String Dim i As Long, n As Long Dim nWJ As Integer, cWJ As String nWJ = FreeFile ' 空闲的文件通道 cWJ = App.Path ' 程序当前所在的绝对路径 If Right(cWJ, 1) <> "\" Then cWJ = cWJ & "\" cWJ = cWJ & "OPJdzb.INI" ' 测试文件的行数:n n = 0 Open cWJ For Input As #nWJ Do While Not (Eof(nWJ)) n = n + 1: Line Input #nWJ, cTS Loop Close #nWJ ' 将文件内容装入数组:cc ReDim cc(1 To n) As String Open cWJ For Input As #nWJ For i = 1 To n: Line Input #nWJ, cc(i): Next Close #nWJ cc(2) = "需要的字符" ' 重新保存文件 Open cWJ For Output As #nWJ For i = 1 To n: Print #nWJ, cc(i): Next Close #nWJ cTS = cWJ & vbCrLf & vbCrLf cTS = cTS & "第二行修改成功!" MsgBox cTS, 0 + 64, "系统提示" End Sub