作者CuckooBoy (书仔)
看板Visual_Basic
标题Re: [VB6 ] 读取txt
时间Sat Jun 28 20:36:21 2008
※ 引述《CuckooBoy (书仔)》之铭言:
: ※ 引述《a9 (a9)》之铭言:
: : Dim f as Integer,sLine As String
: : f=FreeFile '取得一个可用的档案代码
: : Open App.Path & \"Backup.ini" For Input As #f '用Input方式开档
: : While Not EOF(f) '如果还没到档尾
: : Line Input #f,sLine '读取一行
: : '做你要做的事
: : Wend
: : Close#f '关档
: : 如果只要读一行
: : If Not EOF(f) Then Line Input #f,sLine
: Private Sub Form_Load()
: Dim f, cnt As Integer, titledata, autherdata As String
: f = FreeFile
: Open App.Path & "\Backup.ini" For Input As #f
: While Not EOF(f)
: Line Input #f, Data
: cnt = cnt + 1
: Select Case cnt
: Case 1
: Title.Text = Data
: Case 2
: Auther.Text = Data
: Case 3
: Time.Text = Data '时间来源
: Case 4
: Item1.Text = Data '项目1来源
: Case 5
: Item2.Text = Data '项目2来源
: Case 6
: Item3.Text = Data '项目3来源
: Case 7
: Item4.Text = Data '项目4来源
: End Select
: Wend
: Close #f
: End Sub
感谢提醒
Private Sub Form_Load()
Dim f, cnt As Integer, titledata, autherdata, timedata, item1data,
item2data, item3data, item4data As String
f = FreeFile
Open App.Path & "\Backup.ini" For Input As #f
Input #f, titledata, autherdata, timedata, item1data, item2data,
item3data, item4data
Title.Text = titledata '标题来源
Auther.Text = autherdata '作者来源
Time.Text = timedata '时间来源
Item1.Text = item1data '项目1来源
Item2.Text = item2data '项目2来源
Item3.Text = item3data '项目3来源
Item4.Text = item4data '项目4来源
Close #f
End Sub
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 123.195.194.110
※ 编辑: CuckooBoy 来自: 123.195.194.110 (06/28 20:36)
1F:→ MrOrz:对了,那行Dim定义出来的变数,除了cnt和item4data之外,都 06/28 21:34
2F:→ MrOrz:是Variant型态。如果你的原意就是这样,那请当作没看到我的 06/28 21:34
3F:→ MrOrz:推文XD" 06/28 21:34