vb中数组文件

分类:函数知识网浏览量:1493发布于:2021-06-22 00:04:41

vb中数组文件

你的数组 b 定义了吗?加上下面语句试试:Dim b(), n As Longn = 50ReDim b(1 To n)另外,If i Mod 5 = 0 Then Print #1,逗号后面缺少变量,也就是要写入文件的内容.

其实可以用split语句实现 如数据粘贴在c:\1.txt中 dim ins$,i%,data_ins(1000) as single ,temp_data() as single,new_data(1000,1000) 为了保证读取全,定义大数组.也可前

Dim fileName As String Dim startnumber%,endnumber% Const MyFile = 1 Dim i% Dim T() Open fileName For Input As #MyFile '打开文件 Input #MyFile,startnumber ,endnumber '读文件 Redim T(endnumber-startnumber) For i = startnumber To endnumber Input #MyFile, T(i) Next i Close #MyFile '关文件

dim a(225,1) as byteopen "save.dat" for binary as #1put #1,1,aclose #1

Dim n() As String, i As LongDim StrOut As StringPrivate Sub cmdadd_Click()ReDim Preserve n(i) As StringIf i > 0 Then For j = 0 To UBound(n) If cboname.Text = n(j) Then

用split函数可以进行分割文本.如果按回车换行符分割的话,就可以把文本每行分割到一个数组里面去了.想要取第几行可以用 要取的文本=数组(i-1) 这样取.取出数据

在窗体中添加一个text1,一个command1,把fs.txt放到c:\fs.txt双击command1,添加如下代码:Dim fs As IntegerDim a() As Stringfs = FreeFileOpen "c:\fs.txt" For Input

open filename for output as #1for i=lbound(a,1) to ubound(a,1)for j=lbound(a,2) to ubound(a,2)s=""s=s & a(i,j) & iif(j=ubound(a,2),",",)print #1, snextnextclose #1

Dim I As Integer I = 0'将数据放在D:\Test.txt中,打开文本文件 Open "D:\Test.txt" For Input As #1 Do While Not EOF(1) ReDim dm(I), x(I), y(I) Input #1, dm(I), x(I), y(I) '输出数组内容 Picture1.Print dm(I); x(I); y(I) I = I + 1 Loop Close #1

Private Function ReadFile(FileName As String) As String() '读取文件 Dim M() As String ReDim M(1) Dim FileNum As Integer FileNum = FreeFile Open FileName For Input