首页 > 编程 > .NET > 正文

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

2024-07-10 13:01:14
字体:
来源:转载
供稿:网友
开始时引用
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, fileaccess.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




发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表