Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Need a reorg for .NET Framework 4
Message
De
24/07/2010 12:35:04
 
 
À
23/07/2010 12:20:53
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
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:
01473697
Vues:
52
This message has been marked as a message which has helped to the initial question of the thread.
Actually, you're still needlessly jumping through hoops. Take a look at this:
string CRLF = "\r\n";
string TestString = string.Format("Test this string. {0}It contains {1}a CRLF.{2}QED", CRLF, CRLF, CRLF );
string[] lines = TestString.Split(CRLF.ToCharArray(), StringSplitOptions.RemoveEmptyEntries);

for (int i = 0; i < lines.Length; i++)
{
	Debug.WriteLine(lines[i]);
}
~~Bonnie



>The only way to resolve the double character equivalent for a carriage return issue with the Split() method is to parse each item of the array, after it has been created, and call a method that removes carriage returns before and after. So, basically, in the LoadString() method, I have added a For/Next at the end to clean that up. Basically, Split() works on a one delimiter character. But, a carriage return is usually CHR(13)+CHR(10). So, it keeps the CHR(10). I tried to look for an option in it in regards to that but couldn't find it. This is what it gives for the LoadString(), the MemLines() and the MLine() methods. It is faster than before and works ok.
>
>

> ' Load the string into the string builder
> ' expC1 String
> Public Function LoadString(ByVal tcString As String) As Boolean
> Dim lnCounter As Integer = 0
>
> ' Make sure to clear the string builder
> oStringBuilder.Length = 0
>
> oStringBuilder.Append(tcString)
>
> ' Initialize the array
> oLine = oStringBuilder.ToString.Split(oApp.cCR)
>
> ' Count the number of lines
> nLine = MemLines()
>
> ' For each line
> For lnCounter = 1 To nLine
> oLine(lnCounter - 1) = oApp.NoCr(oLine(lnCounter - 1))
> Next
>
> Return True
> End Function
>
> ' Return the number of lines in a string
> Public Function MemLines() As Integer
> Return oLine.Length - 1
> 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
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform