VB問題



贊助商連結


流浪者~MIT
2003-08-21, 09:32 PM
有一個txt檔內容如虛線內:
------------------------
1 -1 1
2.12345
------------------------
程式碼大約是這樣:
Option Explicit
Dim fs As New FileSystemObject
Dim f As TextStream
Dim draw As Boolean
Dim counter As Integer
Set f = fs.OpenTextFile("agree.txt")
If f.AtEndOfStream = False Then counter = f.ReadAll
counter = counter + 1
f.Close
Text2.Text = Format(counter, "00")
Set f = fs.CreateTextFile("agree.txt")
f.Write Text2.Text
f.Close
-------------------------------------------------------
我要如何寫才能使
txt檔案讀出時只讀第二行2.12345

贊助商連結


jute
2003-08-23, 12:12 AM
在 If 那一行之前加個 f.SkipLine 試試?

Set f = fs.OpenTextFile("c:\agree.txt")
f.SkipLine
If f.AtEndOfStream = False Then counter = f.ReadAll

流浪者~MIT
2003-08-24, 12:09 AM
最初由 jute 發表
在 If 那一行之前加個 f.SkipLine 試試?

Set f = fs.OpenTextFile("c:\agree.txt")
f.SkipLine
If f.AtEndOfStream = False Then counter = f.ReadAll
謝謝你,可以了