Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Need a reorg for .NET Framework 4
Message
From
25/07/2010 14:09:59
 
 
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Environment versions
Environment:
VB 9.0
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01473537
Message ID:
01473771
Views:
34
>Now that we are clear on what Michel actually wants in the result the shortest solution seems to be:
>string[] delimiters = new string[] { Environment.NewLine };   //may be safer than "\r\n" ?
>string[] lines = TestString.Split(delimiters,StringSplitOptions.None);
>Again I don't know if performance will be an issue but with 100000 lines of about 100 characters each this is still a sub-millisecond operation on my (average) machine. Ran out of ram trying a million lines tho :-{
>Update: Your version using fluent syntax took pretty much the same time:
string[] lines = TestString.Replace("\r",String.Empty).Split("\n".ToCharArray());
Using that approach, it resolves the issue.
        ' Load the string into the string builder
        ' expC1 String
        Public Function LoadString(ByVal tcString As String) As Boolean
            Dim lcDelimiter As String() = New String() {Environment.NewLine}

            ' Make sure to clear the string builder
            oStringBuilder.Length = 0

            oStringBuilder.Append(tcString)

            ' Initialize the array
            oLine = oStringBuilder.ToString.Split(lcDelimiter, StringSplitOptions.None)

            ' Count the number of lines
            nLine = MemLines()

            Return (True)
        End Function

        ' Return the number of lines in a string
        Public Function MemLines() As Integer
            Return oLine.Length
        End Function

        ' Return the specific line in a string
        ' expN1 Line
        Public Function MLine(ByVal tnLine As Integer) As Boolean

            ' Reset the values
            cLine = ""

            ' If the value passed is smaller or eqaul to the number of lines
            If tnLine - 1 <= nLine Then
                cLine = oLine(tnLine - 1)
            End If

            Return True
        End Function
Before, I was using a direct reference to Environment.NewLine.ToCharArray in this line:
            oLine = oStringBuilder.ToString.Split(Environment.NewLine.ToCharArray, StringSplitOptions.None)
Now, I am using the String() approach. So, maybe this is why it didn't work before.

Thanks
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform