VB读取Text到二维数组 求帮助。代码解释一下最好了。 Vb初学者

VB读取Text到二维数组
文本部分内容如下:
要求只读取文件中那规则的两列数,到一个二维数组。现在是23行要是n行不确定怎么读取?
求大侠先把读取这23行代码详细写一下吧。谢啦。
May 6, 2012 19:58:19
Cyclic Voltammetry
File: e:\c材料\20120125-1\10mv.txt
Data Source: Experiment
Instrument Model: CHI660D
Header:
Note: Init E (V) = 0.1
High E (V) = 0.1
Low E (V) = -0.7
Init P/N = N
Scan Rate (V/s) = 0.01
Segment = 2
Sample Interval (V) = 0.001
Quiet Time (sec) = 2
Sensitivity (A/V) = 1e-4Segment 1:
Ep = -0.215V
ip = 1.309e-4A
Ah = 5.758e-4CSegment 2:
Ep = -0.051V
ip = -9.687e-6A
Ah = -1.101e-4CPotential/V, Current/A0.100, -2.595e-6
0.099, -1.252e-6
0.098, -9.838e-7
0.097, -7.588e-7
0.096, -5.837e-7
0.095, -3.912e-7
0.094, -2.530e-7
0.093, -1.256e-7
0.092, 3.759e-8
0.091, 1.265e-7
0.090, 1.909e-7
0.089, 3.391e-7
0.088, 4.238e-7
0.087, 5.603e-7
0.086, 6.520e-7
0.085, 6.885e-7
0.084, 8.113e-7
0.083, 8.879e-7
0.082, 9.474e-7
0.081, 1.030e-6
0.080, 1.103e-6
0.079, 1.178e-6
0.078, 1.231e-6
最新回答
心有〃余悸

2024-05-19 11:53:02

Private Sub Command1_Click()
Dim i, arr, temp, s, brr() As Double
Open "e:\c材料\20120125-1\10mv.txt" For Input As #1
arr = Split(StrConv(InputB(LOF(1), 1), vbUnicode), vbNewLine)
Close #1
For i = 0 To UBound(arr)
If IsNumeric(Left(arr(i), 1)) And InStr(arr(i), ",") > 0 And InStr(arr(i), "e-") > 0 Then
temp = Split(arr(i), ",")
If UBound(temp) = 1 Then
s = s & arr(i) & vbNewLine
End If
End If
Next
If Len(s) > 0 Then
s = Split(Left(s, Len(s) - 1), vbNewLine)
ReDim brr(UBound(s), 1)
For i = 0 To UBound(s)
brr(i, 0) = Split(s(i), ",")(0): Print brr(i, 0)
brr(i, 1) = Split(s(i), ",")(1): Print brr(i, 1)
Next
End If
End Sub
缠绵不楚

2024-05-19 11:21:25

是读取txt文件,还是text里的文本

自动识别有多少行,保存在x()一维数组中

Dim x()
Private Sub Command1_Click()
Open "e:\c材料\20120125-1\10mv.txt" For Input As 3
Do Until EOF(1)
Line Input #1, a
t = Split(a, ",")
If IsNumeric(t(0)) = True Then
n = n + 1
ReDim Preserve x(n)
x(n) = a
End If
Loop
Close
End Sub