Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Rot-13

Rot-13

Scheduled Pinned Locked Moved Visual Basic
htmlcom
7 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    Lost User
    wrote on last edited by
    #1

    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!


    Extreme Exe

    R C 2 Replies Last reply
    0
    • L Lost User

      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!


      Extreme Exe

      R Offline
      R Offline
      Reuven Elliassi
      wrote on last edited by
      #2

      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 ?

      L 1 Reply Last reply
      0
      • L Lost User

        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!


        Extreme Exe

        C Offline
        C Offline
        ChandraRam
        wrote on last edited by
        #3

        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

        L 1 Reply Last reply
        0
        • R Reuven Elliassi

          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 ?

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          Yes, I want to convert "A to Z" and "B to Y".


          Extreme Exe

          R 1 Reply Last reply
          0
          • C ChandraRam

            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

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #5

            Yes, thank you for pointing that out, but it still doesn't work. Thanks anyway though!


            Extreme Exe

            C 1 Reply Last reply
            0
            • L Lost User

              Yes, thank you for pointing that out, but it still doesn't work. Thanks anyway though!


              Extreme Exe

              C Offline
              C Offline
              ChandraRam
              wrote on last edited by
              #6

              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

              1 Reply Last reply
              0
              • L Lost User

                Yes, I want to convert "A to Z" and "B to Y".


                Extreme Exe

                R Offline
                R Offline
                Reuven Elliassi
                wrote on last edited by
                #7

                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.

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups