Visual Basic.NET(将文本文件导入数组)

发表于:2007-06-30来源:作者:点击数: 标签:
开始时引用 Imports System.IO 按钮的Click事件 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click @#打开目标文件(文件流) Dim myFs As New FileStream(Application.StartupPath a.txt, FileMo
开始时引用
Imports System.IO

按钮的Click事件
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
@#打开目标文件(文件流)
Dim myFs As New FileStream(Application.StartupPath & "a.txt", FileMode.Open, FileAclearcase/" target="_blank" >ccess.Read)
@#读文件
Dim r As New StreamReader(myFs)
Dim i As Integer
Dim myLine, tempStr As String
@#创建数组,接收文件数据
Dim myLineStr(), a(100), b(100) As String
Dim c(100) As Integer
i = 0
myLine = r.ReadLine
Do While Not (myLine Is Nothing)
myLineStr = myLine.Split(",")
a(i) = myLineStr(0)
b(i) = myLineStr(1)
c(i) = myLineStr(2)
i += 1
Loop
End Sub


原文转自:http://www.ltesting.net