-
Line Input gets a line in a text file. Is there something like that against string buffer. Example, Kedaman showed me how to get an entire text file into a string. I want to know if there is a way to go through each carriage return or do I have to program a function that is similar to Line Input.
-
What do you mean by going through each carriage return? In fact Line Input gets a line at a time and each line ends in a carriage return in the file, or, the carriage return is the separator between lines in a file.
-
Thanks for your reply
That is what I want to do. Something similar to Line Input, but for a buffer string that has used the GET method.
-
Sure!
If you have VB6:
Use Split to add each line to an array.
You have VB5? Here's the code for a split function (dunno who wrote it, got the code from kedaman)
Code:
Public Function Split(ByVal sIn As String, Optional sDelim As String, Optional nLimit As Long = -1, Optional bCompare As VbCompareMethod = vbBinaryCompare) As Variant
Dim sRead As String, sOut() As String, nC As Integer
If sDelim = "" Then
Split = sIn
End If
sRead = ReadUntil(sIn, sDelim, bCompare)
Do
ReDim Preserve sOut(nC)
sOut(nC) = sRead
nC = nC + 1
If nLimit <> -1 And nC >= nLimit Then Exit Do
sRead = ReadUntil(sIn, sDelim)
Loop While sRead <> ""
ReDim Preserve sOut(nC)
sOut(nC) = sIn
Split = sOut
End Function
-
Hey don't use that one, it's the slower one, Iain made a much faster one, but, if you are using Vb6 then use the split function implemented there, it's even faster :)
Code:
Private Sub Mysplit(Source, searchs As String, ByRef Arr() As String)
Dim pos As Long, pos2 As Long, x As Long
pos = 0
If Right(Source, Len(searchs)) = searchs Then
Source = Mid$(Source, 1, Len(Source) - Len(searchs))
End If
Do
pos = InStr(pos + 1, Source, searchs, vbTextCompare)
If pos = 0 Then Exit Do
ReDim Preserve Arr(x)
Arr(x) = Mid(Source, pos + 1, pos + Len(searchs) - 2)
x = x + 1
Loop
End Sub
-
<?>
Jop
Your's was written (Originally Posted) by Aaron Young.