在vb中如何将txt文件中的数据读入二维数组,数据有73行,133列,求高手指导!!

 我来答
shianhong1991
2012-05-24 · TA获得超过325个赞
知道答主
回答量:260
采纳率:0%
帮助的人:139万
展开全部
在VB.net2010中我有一个例子
Public Function IDtfmatrx(ByVal s As String) As Single(,)

Dim i As Integer, c1 As String, c2 As String = Nothing
Dim lin As Integer = 0, row As Integer = 0, bl As Boolean = True
For i = 1 To Len(s)
c1 = Mid(s, i, 1)
If c1 = " " And bl = True Then lin = lin + 1
If c1 = Chr(10) Or c1 = Chr(13) Then
row = row + 1
If bl = True Then bl = False

End If
Next
Dim mtr(row, lin) As Single

Dim lin1 As Integer = -1, row1 As Integer = 0
bl = True
Dim bl2 As Boolean
Dim bl3 As Boolean
bl2 = True
bl3 = True
For i = 1 To Len(s)
c1 = Mid(s, i, 1)
If c1 <> Chr(10) And c1 <> Chr(13) And c1 <> " " Then
c2 = c2 & c1
bl2 = True
Else
lin1 = lin1 + 1
If lin1 = lin + 1 Then
row1 = row1 + 1
lin1 = 0
End If
bl2 = False
End If
If bl2 = False Then
mtr(row1, lin1) = Val(c2)
c2 = Nothing
End If
Next
IDtfmatrx = mtr
End Function
这是function可以鉴别一个String里的数据,读入数组中。s中有规定:以空格隔开每个数据,以回车隔开每行数据。当然你说在文本里,那就打开那个文件为Textstream,并且读入s中,在以s为上面function的参数。这个function在VB6里不能用,因为VB6不支持返回二维
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式