dkfr.net
当前位置:首页 >> vB读取txt文件 到数组 >>

vB读取txt文件 到数组

如果TXT文件是单行的话 Open "c:\1.txt" For Binary As #1 Text1.Text = Input(lof(1), 1) Close #1 Dim a a = Split(Text1.Text) 如果是多行要加循环 Option Explicit Dim a$, n%, k%, c$(), d% Private Sub Form_Click() n = 0 Open App.Path ...

dim strline as string dim a() dim i as integer open app.path +"\1.txt for input as #1 do until eof(#1) i=i+1 line input #1,strline redim preserve a(i) a(i-1)=strline loop

Private Sub Command1_Click() Dim arr, i As Long Open "c:\123.txt" For Input As #1 arr = Split(StrConv(InputB(LOF(1), 1), vbUnicode), vbNewLine) Close #1 For i = 0 To UBound(arr) Print arr(i) Next End Sub

Dim A(), B(), C(), D(), E() '数据类型不详,可以不声明数据类型,首先声明动态数组Dim X As Integer, Y As IntegerOpen "C:\ABC\123.txt" For Input As #1 '读取123.txt文本文件的数据If Not EOF(1) ThenX = X + 1 '首先得到文本文件的总行数E...

Private Sub Command1_Click() Dim i As Integer '因为数据里有冒号,所以采用字符串格式 Dim d() As String Dim LStr() As String Dim H As Integer Dim L() As String '先将数据读取到动态数组LStr(),假设文本文件存放于与程序文件同一个文件...

Public Function openfile(ByVal filepath As String) As String Dim s As String Open filepath For Input As #1 While Not EOF(1) Line Input #1, sline s = s & sline & vbCrLf Wend Close #1 openfile = s End Function 如果是按一行一行读...

Dim A(), B(), C(), D(), E() '数据类型不详,可以不声明数据类型,首先声明动态数组 Dim X As Integer, Y As Integer Open "C:\ABC\123.txt" For Input As #1 '读取123.txt文本文件的数据 If Not EOF(1) Then X = X + 1 '首先得到文本文件的总...

Dim 成绩(5) As Single Private Sub Command1_Click() Open "fs.txt" For Input As #1 Text1 = "" For i = 1 To 5 Input #1, 成绩(i) Text1 = Text1 & 成绩(i) & "," Next i Close #1 End Sub Private Sub Command2_Click() Dim 满分人数 As Int...

看你的意思是以行分隔,只须3行代码就可以了 Dim str_All As String = My.Computer.FileSystem.ReadAllText("g:\vb.net\student.txt") Dim str_Sp() As String = str_All.Split(vbCrLf) '以行分隔 TextBox1.Text = str_All

其实可以用split语句实现 如数据粘贴在c:\1.txt中 dim ins$,i%,data_ins(1000) as single ,temp_data() as single,new_data(1000,1000) 为了保证读取全,定义大数组。 也可前面先读一次获取行列数,然后按照读取的行列数定义数组(这里略掉) op...

网站首页 | 网站地图
All rights reserved Powered by www.dkfr.net
copyright ©right 2010-2021。
内容来自网络,如有侵犯请联系客服。zhit325@qq.com