Нужен самый максимальный по скорости метод получения определенной строки из текста.
Слышал про библиотеку для быстрой работы с текстом.
Посоветуйте самый реактивный метод.
|kerish| писал(а):Нужен самый максимальный по скорости метод получения определенной строки из текста.
Слышал про библиотеку для быстрой работы с текстом.
Посоветуйте самый реактивный метод.
Public Function ReadLine(Text As String, NumberLine As Long) As String
Dim Str As String, Ln As String
Dim i As Long
Dim CurLine As Long
Dim CurSym As String
CurLine = 1
Str = Text
On Error Resume Next
For i = 1 To Len(Str)
CurSym = Mid(Str, i, 1)
If CurLine = NumberLine Then
If (Asc(CurSym) <> 10) And (Asc(CurSym) <> 13) Then Ln = Ln & CurSym
End If
If Asc(CurSym) = 13 Then CurLine = CurLine + 1
If CurLine > NumberLine Then GoTo lblexit
Next i
lblexit:
ReadLine = Ln
End Function
Джеффи писал(а):А чем не устраивает Split?
Public Function ReadLine(Text As String, NumberLine As Long) As String
Dim sTemp() As String
On Local Error Resume Next
ReadLine = ""
sTemp = Split(Text, vbCrLf)
If (UBound(sTemp()) + 1) < NumberLine Then
Exit Function
Else
ReadLine = sTemp(NumberLine - 1)
End If
End Function
Public Function ReadLine(Text As String, NumberLine As Long) As String
Dim sTemp() As String
On Local Error Resume Next
ReadLine = ""
sTemp = Split(Text, vbCrLf, NumberLine + 1) 'Изменение
If (UBound(sTemp()) + 1) < NumberLine Then
Exit Function
Else
ReadLine = sTemp(NumberLine - 1)
End If
End Function
Public Function ReadLine(Text As String, NumberLine As Long) As String
Dim sTemp() As String
On Local Error Resume Next
ReadLine = ""
sTemp = Split(Text, vbCrLf, NumberLine + 1)
ReadLine = sTemp(NumberLine - 1)
End Function
Public Function ReadLine(Text As String, NumberLine As Long) As String
On Local Error Resume Next
ReadLine = Split(Text, vbCrLf, NumberLine + 1)(NumberLine - 1)
End Function
Public Function ReadLine(Text As String, ByVal NumberLine As Long) As String
On Local Error Resume Next
ReadLine = Split(Text, vbCrLf, NumberLine + 1)(NumberLine - 1)
End Function
Сейчас этот форум просматривают: нет зарегистрированных пользователей и гости: 172