![]() |
|
[VB.NET/C#] Text Flipping Example - LINQ - Printable Version +- Sinisterly (https://sinister.li) +-- Forum: Coding (https://sinister.li/Forum-Coding) +--- Forum: Visual Basic & .NET Framework (https://sinister.li/Forum-Visual-Basic-NET-Framework) +--- Thread: [VB.NET/C#] Text Flipping Example - LINQ (/Thread-VB-NET-C-Text-Flipping-Example-LINQ) |
[VB.NET/C#] Text Flipping Example - LINQ - ArkPhaze - 04-11-2012 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[VB.NET/C#] Text Flipping Example - LINQ - ArkPhaze - 04-11-2012 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 ClassRE: [VB.NET/C#] Text Flipping Example - LINQ - #Swag_mybb_import6403 - 04-15-2012 Thanks for sharing. I've never considered doing this before. RE: [VB.NET/C#] Text Flipping Example - LINQ - #Swag_mybb_import6403 - 04-15-2012 Thanks for sharing. I've never considered doing this before. RE: [VB.NET/C#] Text Flipping Example - LINQ - ArkPhaze - 04-15-2012 Finally... My first reply where ever i've posted this lol. Wow. Thanks
RE: [VB.NET/C#] Text Flipping Example - LINQ - ArkPhaze - 04-15-2012 Finally... My first reply where ever i've posted this lol. Wow. Thanks
RE: [VB.NET/C#] Text Flipping Example - LINQ - #Swag_mybb_import6403 - 04-15-2012 (04-15-2012, 06:46 AM)PhazeShift Wrote: Finally... My first reply where ever i've posted this lol. Wow. lol no problem, the same thing happens to me all the time. Basically, if your code isn't for a keylogger, rat, or any other type of malware you won't get many replies.
RE: [VB.NET/C#] Text Flipping Example - LINQ - #Swag_mybb_import6403 - 04-15-2012 (04-15-2012, 06:46 AM)PhazeShift Wrote: Finally... My first reply where ever i've posted this lol. Wow. lol no problem, the same thing happens to me all the time. Basically, if your code isn't for a keylogger, rat, or any other type of malware you won't get many replies.
|