Re: [.NET] 請問一個讀檔的問題
看板Visual_Basic作者williewillie (williewillie)時間14年前 (2010/05/25 17:05)推噓0(0推 0噓 0→)留言0則, 0人參與討論串2/2 (看更多)
※ 引述《sgygs ()》之銘言:
: 請輸入專案類型(網站專案或者應用程式專案): VB2008 express
: 小弟想寫一個程式可以讀文字檔內的數據,並放入2維陣列中以進行相關運算
: 文字檔的格式如下,共二個行N個欄位,二行數據間隔5個空格。
: 34.253 56.588
: 22.685 63.475
: . .
: . .
: . .
Private Sub Button_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button.Click
'FileNumber
Dim fileNum As Integer = FreeFile()
'FilePath
Dim FilePath As String = "C:\Test.bat"
'Open
FileOpen(fileNum, FilePath, OpenMode.Input)
'Dim Array
Dim StrArray As New ArrayList
'ReadFile
Do Until EOF(fileNum)
StrArray.Add(LineInput(fileNum))
Loop
'Close
FileClose(FileNum)
'OutPut
For i As Integer = 0 To StrArray.Count - 1
'ShowValue
Dim Rstr As String = StrArray(i).ToString.Replace(" ", ",")
Dim str() As String = Rstr.Split(",")
'TextBox1
TextBox1.Text = str(0)
'TextBox2
TextBox2.Text = str(1)
'Sleep
Sleep(1000)
Next
End Sub
大概就是這樣
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 61.219.126.42
※ 編輯: williewillie 來自: 61.219.126.42 (05/25 17:07)
討論串 (同標題文章)
本文引述了以下文章的的內容:
完整討論串 (本文為第 2 之 2 篇):