[VB.NET/C#] Text Flipping Example - LINQ 04-11-2012, 11:25 PM
#1
Code:
Private Shared Function TextFlip(InputString As String) As String
Dim X() As Char = "¿/˙'\‾¡zʎxʍʌnʇsɹbdouɯlʞɾıɥƃɟǝpɔqɐ".ToCharArray, _
V As String = "?\.,/_!zyxwvutsrqponmlkjihgfedcba"
Return StrReverse(New String((From Obj As Char In InputString.ToCharArray()
Select If(V.IndexOf(Obj) <> -1, X(V.IndexOf(Obj)), Obj)).ToArray))
End FunctionCode:
private string TextFlip(string InputString)
{
char[] X = @"¿/˙'\‾¡zʎxʍʌnʇsɹbdouɯlʞɾıɥƃɟǝpɔqɐ".ToCharArray();
string V = @"?\.,/_!zyxwvutsrqponmlkjihgfedcba";
return new string((from char obj in InputString.ToCharArray()
select (V.IndexOf(obj) != -1) ? X[V.IndexOf(obj)] : obj).Reverse().ToArray());
}I seen someone post an extensive code on this somewhere else, and decided to simplify it.
Here was the extended and convoluted version:
Spoiler:
Code:
Public Class Form1
Dim X As String = "¿/˙'\‾¡zʎxʍʌnʇsɹbdouɯlʞɾıɥƃɟǝpɔqɐ", _
V As String = "?\.,/_!zyxwvutsrqponmlkjihgfedcba"
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
Dim str As String, Newstr As String = Nothing
str = TextBox1.Text
For Each StrText As String In str
Select Case True
Case StrText = "b"
StrText = "p"
Case StrText = "p"
StrText = "b"
Case StrText = "q"
StrText = "d"
Case StrText = "d"
StrText = "q"
Case StrText = "u"
StrText = "n"
Case True
For I = 0 To X.Length - 1
StrText = StrText.Replace(V.ElementAt(I), _
X.ElementAt(I))
Next
End Select
Newstr &= StrText
Next
TextBox2.Text = Newstr
TextBox2.Text = StrReverse(TextBox2.Text)
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
End Class
ArkPhaze
"Object oriented way to get rich? Inheritance"
Getting Started: C/C++ | Common Mistakes
[ Assembly / C++ / .NET / Haskell / J Programmer ]
"Object oriented way to get rich? Inheritance"
Getting Started: C/C++ | Common Mistakes
[ Assembly / C++ / .NET / Haskell / J Programmer ]


![[+]](https://sinister.li/images/modern/collapse_collapsed.png)