作者williewillie (williewillie)
看板Visual_Basic
标题Re: [.NET] 请问一个读档的问题
时间Tue May 25 17:05:00 2010
※ 引述《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)