Results 1 to 6 of 6

Thread: Just For Fun -- Scramble Text

  1. #1

    Thread Starter
    Frenzied Member macai's Avatar
    Join Date
    Jul 2001
    Location
    Napanoch NY
    Posts
    1,228

    Just For Fun -- Scramble Text

    Hey guys. I'm just doing this for fun, and if you are interested in my little twisted nerdy game, here are the objectives.

    1) Find a way to take the values of a string, and move them to different places.
    2) Do not use randomization. The same string always gets scrambled the same way.

    So heres my way:
    VB Code:
    1. x = StrReverse(Mid$(x, 1, Len(x) / 2)) & StrReverse(Mid$(x, Len(x) / 2, Len(x) / 2))
    Last edited by macai; Jan 25th, 2003 at 05:04 AM.
    Luke

  2. #2
    Frenzied Member KayJay's Avatar
    Join Date
    Jul 2001
    Location
    Chennai
    Posts
    1,849
    here is the complete app.

    It ROT Encryption.
    Attached Files Attached Files

    "Brothers, you asked for it."
    ...Francisco Domingo Carlos Andres Sebastian D'Anconia

  3. #3
    Frenzied Member KayJay's Avatar
    Join Date
    Jul 2001
    Location
    Chennai
    Posts
    1,849
    A bug.

    Add this in the form load event
    VB Code:
    1. With Combo1
    2. .AddItem "1 - CharsetALL"
    3. .AddItem "2 - CharsetAlphaNumeric"
    4. .AddItem "3 - CharsetAlpha"
    5. End With

    "Brothers, you asked for it."
    ...Francisco Domingo Carlos Andres Sebastian D'Anconia

  4. #4

    Thread Starter
    Frenzied Member macai's Avatar
    Join Date
    Jul 2001
    Location
    Napanoch NY
    Posts
    1,228
    that dosen't fit the requirements. that encrypts it.

    what i mean by scrambling is like taking, say the string "Hello" and algorythmically taking it apart and moving the parts of the string around. Like my method did this

    First, it takes the first to halves "he" & "ll" and reverses them and puts the first letter at the last as a replacement for the last like so:"ehllh" Thats what i mean by scrambling.
    Luke

  5. #5
    Frenzied Member KayJay's Avatar
    Join Date
    Jul 2001
    Location
    Chennai
    Posts
    1,849
    thats prcisely what it does. In the module, there is a sub "FillBaseKey". there
    VB Code:
    1. Select Case CharacterSet
    2.             Case Is = 1
    3.                 BaseKeyChars = "mxnc5bvalskdj1fhgqpwoe2irtuy3VCBNX4MZGFHD8JKSAL9YOWP0QIERU6T7z !@#$%^&*()-=\_+|[];" & "'" & """" & ":,./?{}`~"
    4.             Case Is = 2
    5.                 BaseKeyChars = "QwErTyUiOp98AsDfGhJk76LzXcVb45NmqWeRtYuIoPaSd32FgHjKlZxCvBnM01"
    6.             Case Is = 3
    7.                 BaseKeyChars = "pZzXoxVPicCuOBvybIYMNtAnrSEmDewGqaUlHskKdFjJfhgLQRTW"
    8.         End Select

    The "basekeychars" can be set to the string U want to be jumbled. So for a string "Hello. How are you?", if the BaseKeyChars is set to the same string and if the number of chatcters U want rotated is "3" and the number of passes is just "1", Each character will be roted in turn. The same letters will return jumbled.

    HTH


    "Brothers, you asked for it."
    ...Francisco Domingo Carlos Andres Sebastian D'Anconia

  6. #6
    PowerPoster
    Join Date
    Jun 2001
    Location
    Trafalgar, IN
    Posts
    4,141
    To just scramble the characters, this should work.
    VB Code:
    1. Option Explicit
    2. Dim col As Collection
    3.  
    4. Private Sub Command1_Click()
    5. Dim i As Integer
    6. Dim strTemp As String
    7.  
    8. '   Create the collection
    9.     Set col = New Collection
    10.    
    11. '   Extract a letter from the sting one at a time and add it to the collection
    12.     For i = 1 To Len(Text1.Text)
    13.         col.Add Mid$(Text1.Text, i, 1), Str(i)
    14.     Next i
    15.        
    16.     Randomize
    17.  
    18. '   Loop through the collection to get the letters in a random order
    19.     Do While col.Count > 0
    20. '       Get a random item number
    21.         i = Int(Rnd() * (col.Count)) + 1
    22. '       Add the random letter to a temp string
    23.         strTemp = strTemp & col.Item(i)
    24. '       Remove the letter from the collection so it isn't used again
    25.         col.Remove i
    26.     Loop
    27.    
    28. '   Show your results
    29.     Text2.Text = strTemp
    30.    
    31. End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width