-
Nov 11th, 2000, 10:46 PM
#1
Thread Starter
Addicted Member
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.
-
Nov 12th, 2000, 12:42 AM
#2
Addicted Member
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.
-
Nov 12th, 2000, 12:51 AM
#3
Thread Starter
Addicted Member
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.
-
Nov 12th, 2000, 09:02 AM
#4
Frenzied Member
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
Jop - validweb.nl
Alcohol doesn't solve any problems, but then again, neither does milk.
-
Nov 12th, 2000, 09:13 AM
#5
transcendental analytic
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
Use
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Nov 12th, 2000, 11:47 AM
#6
_______
<?>
Jop
Your's was written (Originally Posted) by Aaron Young.
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|