То что сделал, работает но медленно, помогите ускорить.
И еще, как поступить, чтобы записать все данные из этих 4 массивов в один файл
(сейчас каждый массив в свой файл) и потом восстановить из файла?
- Код: Выделить всё
Private Type tVal1
Val1 As Double
Val2 As Double
Val3 As Double
End Type
Private Type tVal2
Val1 As Long
Val2 As Long
Val3 As Long
End Type
Private dVal1() As Double
Private dVal2() As Double
Private arVal1() As tVal1
Private arVal2() As tVal2
‘Сохранение
Dim i As Long
Dim iFF As Long
iFF = FreeFile()
Open NewName1 For Output As #iFF
For i = 0 To UBound(dVal1())
Print #iFF, dVal1(i)
Next i
Close #iFF
iFF = FreeFile()
Open NewName2 For Output As #iFF
For i = 0 To UBound(dVal2())
Print #iFF, dVal2(i)
Next i
Close #iFF
iFF = FreeFile()
Open NewName3 For Output As #iFF
For i = 0 To UBound(arVal1())
Print #iFF, Trim$(arVal1(i).Val1) & ";" & Trim$(arVal1(i).Val2) & ";" & Trim$(arVal1(i).Val3)
Next i
Close #iFF
iFF = FreeFile()
Open NewName4 For Output As #iFF
For i = 0 To UBound(arVal2())
Print #iFF, Trim$(arVal2(i).Val1) & ";" & Trim$(arVal2(i).Val2) & ";" & Trim$(arVal2(i).Val3)
Next i
Close #iFF
‘Чтение
Dim i As Long, l As Long
Dim iFF As Long
Dim sTempLine() As String
Dim vTempArray As Variant
i = 0
iFF = FreeFile()
Open NewName1 For Input As #iFF
Do While Not EOF(iFF)
ReDim Preserve sTempLine(i)
Line Input #iFF, sTempLine(i)
i = i + 1
Loop
Close #iFF
l = UBound(sTempLine)
ReDim dVal1(0 To l)
For i = 0 To l
dVal1(i) = CDbl(sTempLine(i))
Next i
Erase sTempLine()
i = 0
iFF = FreeFile()
Open NewName2 For Input As #iFF
Do While Not EOF(iFF)
ReDim Preserve sTempLine(i)
Line Input #iFF, sTempLine(i)
i = i + 1
Loop
Close #iFF
l = UBound(sTempLine)
ReDim dVal2(0 To l)
For i = 0 To l
dVal2(i) = CDbl(sTempLine(i))
Next i
Erase sTempLine()
i = 0
iFF = FreeFile()
Open NewName3 For Input As #iFF
Do While Not EOF(iFF)
ReDim Preserve sTempLine(i)
Line Input #iFF, sTempLine(i)
i = i + 1
Loop
Close #iFF
l = UBound(sTempLine)
ReDim arVal1(0 To l)
For i = 0 To l
If Len(Trim$(sTempLine(i))) > 0 Then
vTempArray = Split(Trim$(sTempLine(i)), ";", , vbBinaryCompare)
arVal1(i).Val1 = CLng(vTempArray(0))
arVal1(i).Val2 = CLng(vTempArray(1))
arVal1(i).Val3 = CLng(vTempArray(2))
End If
Next i
Erase sTempLine()
i = 0
iFF = FreeFile()
Open NewName4 For Input As #iFF
Do While Not EOF(iFF)
ReDim Preserve sTempLine(i)
Line Input #iFF, sTempLine(i)
i = i + 1
Loop
Close #iFF
l = UBound(sTempLine)
ReDim arVal2(0 To l)
For i = 0 To l
If Len(Trim$(sTempLine(i))) > 0 Then
vTempArray = Split(Trim$(sTempLine(i)), ";", , vbBinaryCompare)
arVal2(i).Val1 = CDbl(vTempArray(0))
arVal2(i).Val2 = CDbl(vTempArray(1))
arVal2(i).Val3 = CDbl(vTempArray(2))
End If
Next i