Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Need a reorg for .NET Framework 4
Message
De
22/07/2010 18:03:04
 
 
À
Tous
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Titre:
Need a reorg for .NET Framework 4
Versions des environnements
Environment:
VB 9.0
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01473537
Message ID:
01473537
Vues:
134
This code used to run extremely fast before I moved to .NET Framework 4.
        ' Return the specific line in a string
        ' expN1 Line
        Public Function MLine(ByVal tnLine As Integer) As Boolean
            Dim lnLocation As Integer = 0
            Dim loStringBuilderValueAdjusted As StringBuilder = New StringBuilder()

            ' If the line requested is greather than the number of lines
            If tnLine > nLine Then
                cLine = ""
                Return True
            End If

            ' If we are requesting the first ilne
            If tnLine = 1 Then

                ' See if we have more than one line
                If nLine > 1 Then
                    cLine = Mid(oStringBuilder.ToString, 1, InStr(oStringBuilder.ToString, oApp.cCR) - 1)
                Else
                    cLine = oStringBuilder.ToString
                End If

            Else

                ' Make sure we are able to find a carriage return
                lnLocation = oApp.At(oApp.cCR, oStringBuilder.ToString, tnLine - 1)
                If lnLocation > 0 Then
                    loStringBuilderValueAdjusted.Append(Mid(oStringBuilder.ToString, _
                     oApp.At(oApp.cCR, oStringBuilder.ToString, tnLine - 1) + 2))

                    ' If this is not the last line
                    lnLocation = InStr(loStringBuilderValueAdjusted.ToString, oApp.cCR)
                    If lnLocation > 0 Then
                        cLine = Mid(loStringBuilderValueAdjusted.ToString, 1, _
                         InStr(loStringBuilderValueAdjusted.ToString, oApp.cCR) - 1)
                    Else
                        cLine = loStringBuilderValueAdjusted.ToString
                    End If

                Else
                    cLine = oStringBuilder.ToString
                End If
            End If

            Return True
        End Function
Basically, this code returns a specific line from a string. It was originally designed to match the MLine() function of VFP. But, now, under the .NET Framework 4.0, this runs extremely slow. The greater the number of lines in the string, the more the duration in time it takes to find the line.

So, basically, I read a directory having 1000 files. This goes into a string. Then, I use the number of carriage returns to locate the start of the string and get the line associated to it. But, I have to find another approach. Does anyone would have a better function to return a specific line from a string?
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
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform