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 如果是按一行一行读...

VB.NET编程读取txt文本文档中的数据,并把数据保存为数组,代码如下: '写配件文件Private Sub saveIni(ByVal filePath As String, ByVal str As String)Dim sw As StreamWriter = New StreamWriter(filePath, True) 'true是指以追加的方式打开...

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 '首先得到文本文件的总...

看你的意思是以行分隔,只须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

如果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.P...

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