Try:Regards,VB Code:
Private Function SplitEx(ByVal sString As String, Optional ByVal sDelim As String = " ") As Variant Dim sItem As String Dim sList() As String Dim lChar As Long Dim lCount As Long Do ' Reset Split for non-Quoted Values lChar = InStr(sString, sDelim) If lChar > 0 Then ' Extract the Item from the String sItem = Left(sString, lChar - 1) ' Remove Item from the Remaining String sString = Mid(sString, lChar + Len(sDelim)) Else ' Remaining String, becomes final Item sItem = sString sString = "" End If ' If something was extracted, add it to the Array If Len(sItem) > 0 Then ReDim Preserve sList(lCount) sList(lCount) = sItem lCount = lCount + 1 End If ' Continue until no more delimiters are found. Loop While lChar > 0 ' If there were items, return the array If lCount > 0 Then SplitEx = sList Else ' Otherwise return an empty array SplitEx = Array() End If End Function Private Sub Command1_Click() Dim intFree As Integer Dim strReadText As String Dim strTextLines() As String intFree = FreeFile Open "C:\SomeFile.txt" For Binary As #intFree strReadText = Space$(LOF(intFree)) Get #intFree, , strReadText Close #intFree ' Create array of text lines from the file... strTextLines = SplitEx(strReadText, vbNewLine) Text1.Text = strTextLines(0) ' First line... Text2.Text = strTextLines(1) ' Second line... End Sub
- Aaron.




Reply With Quote