Rot-13
-
I am trying to convert all text in a Rich Text Box to Rot-13. But the code I am using doesn't work. By not working I mean it doesn't convert.
Dim AllText As String AllText = RichTextBox.Text Dim Part As Integer Part = AllText.IndexOf("a") Dim FileName As String FileName = AllText.Replace(Part, "Z") Dim Part2 As Integer Part = AllText.LastIndexOf("b") FileName = AllText.Replace(Part2, "Y")
Any suggestions would be appreciated. :) Thank you!
-
I am trying to convert all text in a Rich Text Box to Rot-13. But the code I am using doesn't work. By not working I mean it doesn't convert.
Dim AllText As String AllText = RichTextBox.Text Dim Part As Integer Part = AllText.IndexOf("a") Dim FileName As String FileName = AllText.Replace(Part, "Z") Dim Part2 As Integer Part = AllText.LastIndexOf("b") FileName = AllText.Replace(Part2, "Y")
Any suggestions would be appreciated. :) Thank you!
Please define your need. Do you want to change A to Z, a to z, B to Y, b to y and so on for all the ABC ?
-
I am trying to convert all text in a Rich Text Box to Rot-13. But the code I am using doesn't work. By not working I mean it doesn't convert.
Dim AllText As String AllText = RichTextBox.Text Dim Part As Integer Part = AllText.IndexOf("a") Dim FileName As String FileName = AllText.Replace(Part, "Z") Dim Part2 As Integer Part = AllText.LastIndexOf("b") FileName = AllText.Replace(Part2, "Y")
Any suggestions would be appreciated. :) Thank you!
UltraCoder wrote:
Dim Part2 As Integer Part = AllText.LastIndexOf("b") FileName = AllText.Replace(Part2, "Y")
Are you sure the code is right? Shouldn't it be Part2 = AllText.LastIndexOf("b") Chandra
-
Please define your need. Do you want to change A to Z, a to z, B to Y, b to y and so on for all the ABC ?
-
UltraCoder wrote:
Dim Part2 As Integer Part = AllText.LastIndexOf("b") FileName = AllText.Replace(Part2, "Y")
Are you sure the code is right? Shouldn't it be Part2 = AllText.LastIndexOf("b") Chandra
-
UltraCoder wrote:
Dim AllText As String AllText = RichTextBox.Text Dim Part As Integer Part = AllText.IndexOf("a") Dim FileName As String FileName = AllText.Replace(Part, "Z") Dim Part2 As Integer Part = AllText.LastIndexOf("b") FileName = AllText.Replace(Part2, "Y")
Maybe you can try this?
Dim s as String Dim s1 as String Dim i as Integer s = RichTextBox.Text For i = Asc("a") To Asc("z") s = Replace(s, Chr(i), Chr(i - 32)) ' - 32 gives upper case Next i s1 = "" For i = 1 To Len(s) s1 = s1 & Chr(Asc(Mid(s, i, 1)) + (25 - 2 * (Asc(Mid(s, i, 1)) - 65))) Next i
Hope this helps Chandra -
Try this:
Dim S As String = RichTextBox.Text Dim I As Integer For I=0 To S2Rot13.Length - 1 If Asc(S(I)) >= Asc("a") AndAlso Asc(S(I)) <= Asc("z") Then S(I) = Chr(Asc(S(I)) - 32) ' TO UPPER CASE ElseIf Asc(S(I)) >= Asc("A") AndAlso Asc(S(I)) <= Asc("Z") Then S(I) = Chr(Asc(S(I)) + 32) ' to lower case End If Next I
Instead of going on every letter of the ABC and the abc, we going on the string and check the Ascii code. This saving time if its string that smaller the 46 characters - instead of running 46 times every call we run as long as the string.