Please, take a moment of your time to consider the plight of the poor 'for' loop and its sister 'case' in the below code which has chosen to remain anonymous as per its submitter.
Torn from their mother at an early age, they toil, day and night without rest, as a cog in some oversized corporate wheel. They are forced, often brutally, to piecemeal together a hopefully valid telephone number from the leftovers of a processed string. They're tired, hungry, and begging for retirement to that place in the sky where all bloated code goes when it dies.
So, please, send whatever you can (really, anything will do) to the For Loop Liberation Front world headquarters.
For Loop Liberation Front
44 Front St. 2nd Floor
Berea, OH 44017
If you include a SASE, you'll recieve a Daily WTF sticker or two as a "thank you" for supporting this cause.
Public Shared Function ApplyPhoneNumberFormatting(ByVal phoneNumber As String) As StringDim cleanPhoneNumber As StringDim formattedPhoneNumber As New System.Text.StringBuilderDim i As IntegerIf phoneNumber Is Nothing ThenReturn String.EmptyEnd IfcleanPhoneNumber = StripNonNumericCharacters(phoneNumber)If cleanPhoneNumber.Length = 0 ThenReturn String.EmptyElseFor i = 0 To 12Select Case iCase 0formattedPhoneNumber.Append("(")Case 1formattedPhoneNumber.Append(cleanPhoneNumber.Chars(0))Case 2formattedPhoneNumber.Append(cleanPhoneNumber.Chars(1))Case 3formattedPhoneNumber.Append(cleanPhoneNumber.Chars(2))Case 4formattedPhoneNumber.Append(") ")Case 5formattedPhoneNumber.Append(cleanPhoneNumber.Chars(3))Case 6formattedPhoneNumber.Append(cleanPhoneNumber.Chars(4))Case 7formattedPhoneNumber.Append(cleanPhoneNumber.Chars(5))Case 8formattedPhoneNumber.Append("-")Case 9formattedPhoneNumber.Append(cleanPhoneNumber.Chars(6))Case 10formattedPhoneNumber.Append(cleanPhoneNumber.Chars(7))Case 11formattedPhoneNumber.Append(cleanPhoneNumber.Chars(8))Case 12formattedPhoneNumber.Append(cleanPhoneNumber.Chars(9))End SelectNextReturn formattedPhoneNumber.ToStringEnd IfEnd Function