Err
Active Member
- Joined
- Nov 16, 2006
- Messages
- 274
Here is the piece of code that is bugging me.
Here is a sample text file:
In typical word fashion... each paragraph just drones on until there is an actual carriage return. I would like for this function to split up the entire string into it's individual substrings and hold them as an array... so that I can put them back together again at my leisure.
The problem is that I'm having trouble telling the split function to look for the end of line...
Code:
Public Function Convert_File(from_file As String) As Variant
Dim fso As Object
Dim fil As Object
Dim txt As Object
Dim strtxt As String
Dim stringArray() As String
Dim string_arrayPiece() As Variant
Dim string_arrayE As Variant 'array element
Dim repost_String As String
Dim i As Integer
LastNonEmpty = -1
repost_String = ""
Dim n As Long
'filesyestem object that we need to manage files
Set fso = CreateObject("Scripting.FileSystemObject")
'File that we like to open and read
Set fil = fso.GetFile(from_file)
'Opening file as a text string
Set txt = fil.OpenAsTextStream(1)
strtxt = txt.ReadAll
'closes TextStream and free the file as we don't need it anymore
txt.Close
stringArray() = Split(strtxt, vbCrLf)
'get size
ReDim string_arrayPiece(UBound(stringArray()), 1)
Convert_File = stringArray()
End Function
Here is a sample text file:
Code:
WHEREAS, the Landlord has entered into a Landlord Services Agreement with Rent_insanity.com pursuant to
which Landlord has agreed to accept rent payments from Rent_insanity.com and agreed to pay Rent_insanity.com a fee;
WHEREAS, Rent_insanity.com desires to provide its default reduction services on the Client's behalf, on the
terms set forth herein; and
NOW THEREFORE, in consideration of the mutual covenants expressed herin and for the
good and valuable consideration, the revept and sufficiency of which are hereby acknowledged, and
intending to be legally bound, the parties agree as follows:
1.1. Agency Appointment; Services. Client appoints Rent_insanity.com as its agent to reduce Rent default to its
Landlord in accordance with the terms of this Agreement. Rent_insanity.com will receive funds transferred to
Rent_insanity.com at the direction of and on behalf of the Client and on the date of each month set forth on the
signature page hereto (the 'Rent Transfer Date'), Rent_insanity.com, will transfer to the Landlord, on behalf of the
Client, such funds held by Rent_insanity.com equal to the monthly rent due and payable (the 'Rent Payment')
under the Lease and specified on the Signature Page hereto, subject to the terms and conditions of
this Agreement (the 'Services').
In typical word fashion... each paragraph just drones on until there is an actual carriage return. I would like for this function to split up the entire string into it's individual substrings and hold them as an array... so that I can put them back together again at my leisure.
The problem is that I'm having trouble telling the split function to look for the end of line...