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

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

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...

你要做什么计算?aa和bb都可以用于计算的 Private Sub Command1_Click() Dim aa(), bb(), a, b, n As Integer, i As Integer, fname As String fname = "d:\1.txt" '文件名,可自行更改 '获得文本文件的行数,实际行数为n+1 Open fname For Bina...

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(),假设文本文件存放于与程序文件同一个文件...

代码及注释如下: Dim aa$, s, ss'定义变量 Private Sub Form_Load() Open "c:\temp.txt" For Input As #1'打开txt文件 aa = StrConv(InputB(LOF(1), 1), vbUnicode)'将文本读入aa中 Close #1'关闭文件 End Sub Private Sub Command1_Click() s ...

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

如下: Private Sub Output_Click() Dim filePath As String Dim fileNo As Integer Dim i As Integer On Error GoTo err1 With CommonDialog1 .DialogTitle = "请输入文件名" .Filter = "文本文档(*.txt)|*.txt" .InitDir = App.Path .CancelErr...

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

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