Results 1 to 10 of 10

Thread: Scramble Text

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2001
    Posts
    297

    Scramble Text

    Here is what I ahve

    Code:
    Function ScrambleText(Thetext As String)
        'sees if there's a space in the text to
        '     be scrambled,
        'if found space, continues, if not, adds
        '     it
        findlastspace = Mid(Thetext, Len(Thetext), 1)
    
    
        If Not findlastspace = " " Then
            Thetext = Thetext & " "
        Else
            Thetext = Thetext
        End If
        'Scrambles the text
    
    
        For scrambling = 1 To Len(Thetext)
            thechar$ = Mid(Thetext, scrambling, 1)
            Char$ = Char$ & thechar$
    
    
            If thechar$ = " " Then
                'takes out " " space from the text left
                '     of the space
                chars$ = Mid(Char$, 1, Len(Char$) - 1)
                'gets first character
                firstchar$ = Mid(chars$, 1, 1)
                'gets last character (if not, makes firs
                '     t character only)
                On Error GoTo cityz
                lastchar$ = Mid(chars$, Len(chars$), 1)
                'finds what is inbetween the last and fi
                '     rst character
                midchar$ = Mid(chars$, 2, Len(chars$) - 2)
                'reverses the text found in between the
                '     last and first
                'character
    
    
                For SpeedBack = Len(midchar$) To 1 Step -1
                    backchar$ = backchar$ & Mid$(midchar$, SpeedBack, 1)
                Next SpeedBack
                GoTo sniffe
                'adds the scrambled text to the full scr
                '     ambled element
    cityz:
                scrambled$ = scrambled$ & firstchar$ & " "
                GoTo sniffs
    sniffe:
                scrambled$ = scrambled$ & lastchar$ & firstchar$ & backchar$ & " "
                'clears character and reversed buffers
    sniffs:
                Char$ = ""
                backchar$ = ""
            End If
        Next scrambling
        'Makes function return value the scrambl
        '     ed text
        ScrambleText = scrambled$
    End Function
    usage i tried real quick

    ScrambleText(Text1.Text)


    it keeps saying compile error and highlighting this line

    Code:
        findlastspace = Mid(Thetext, Len(Thetext), 1)
    it highlights findlastspace

  2. #2
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    what is the compile error? Are you using Option Explicit? If so, findlastspace is not declared

    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2001
    Posts
    297
    thats exactly what i'm getting...i get that all the time..how do i define it?

  4. #4
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    It looks like you should declare it as a string
    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2001
    Posts
    297
    ok i'm gonna try it brb

  6. #6

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2001
    Posts
    297
    ya that worked..but i can't figure out the usage...it keeps saying argument not optional

  7. #7
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    on that same line?
    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  8. #8

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2001
    Posts
    297
    no the way i'm using it is getting highlighted like


    ScrambleText (Text1.Text)

    its highlighting ScrambleText..almost like i'm spelling it wrong or something

  9. #9

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2001
    Posts
    297
    even if i do

    Private Sub Command2_Click()
    ScrambleText
    End Sub

    it highlights it and says argument not optional..***

  10. #10
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    well, the function should explicitly return a string, which it doesn't now.

    Function ScrambleText(Thetext As String)

    should be

    Function ScrambleText(Thetext As String) As String

    also, try this way

    ScrambleText (Text1.Text)

    without the parenthesis
    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

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