vb 将计算出的数据添加到txt文件中
Private Sub Form_Click()Dim reg As New RegExp
reg.Pattern = "[\d\.]+"
reg.Global = True: reg.IgnoreCase = True: reg.MultiLine = True
Dim textline As String
Dim temp() As String '第n行的x和y
Dim temp1() As String '第n+1行的x和y
Dim temp2() As String '第n行的时间
Dim temp3() As String '第n+1行的时间
Dim distance() As String
Dim timeInterval() As String
Dim speed() As String
Open "e:\data.txt" For Input As #1
ReDim temp(1)
ReDim temp1(0)
ReDim temp2(2)
ReDim temp3(0)
ReDim distance(0)
ReDim timeInterval(0)
ReDim speed(0)
Do While Not EOF(1)
Line Input #1, textline
temp(0) = reg.Execute(textline)(3) 'x
temp(1) = reg.Execute(textline)(4) 'y
If (UBound(temp1) >= 1) Then
distance(0) = (temp(0) - temp1(0)) ^ 2 + (temp(1) - temp1(1)) ^ 2
Print textline, distance(0)
End If
ReDim temp1(1)
temp1(0) = reg.Execute(textline)(3)
temp1(1) = reg.Execute(textline)(4)
Loop
Close #1
End Sub
Private Sub Form_Load()
End Sub
计算结果如下:
在要保留原数据(前三列)的情况下,怎么把计算出来的结果distance(最后一列是计算结果distance) ,写入txt的最后一列???????
txt中原数据如下:
14:04:16 31.0042 121.19409
14:04:57 31.004078 121.191348
14:05:08 31.00401 121.190088
14:05:25 31.0039 121.187448
14:05:28 31.003878 121.18694
14:05:39 31.00384 121.18541
最终想要的txt中的数据格式是:
14:04:16 31.0042 121.19409 7.53344799998821E-06(手工录入最后一列,哭)
14:04:57 31.004078 121.191348 1.59222400000498E-06(手工录入最后一列,哭)
14:05:08 31.00401 121.190088 6.98169999999739E-06(手工录入最后一列,哭)
14:05:25 31.0039 121.187448 2.5854799999964E-06(手工录入最后一列,哭)
14:05:28 31.003878 121.18694 2.34234400000757E-06(手工录入最后一列,哭)
14:05:39 31.00384 121.18541
在要保留原数据(前三列)的情况下,怎么把计算出来的结果distance(最后一列是计算结果distance) ,写入txt的最后一列???????