|
-
Aug 13th, 2001, 07:08 PM
#1
Thread Starter
Hyperactive Member
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
-
Aug 13th, 2001, 07:10 PM
#2
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
-
Aug 13th, 2001, 07:13 PM
#3
Thread Starter
Hyperactive Member
thats exactly what i'm getting...i get that all the time..how do i define it?
-
Aug 13th, 2001, 07:17 PM
#4
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
-
Aug 13th, 2001, 07:19 PM
#5
Thread Starter
Hyperactive Member
-
Aug 13th, 2001, 07:20 PM
#6
Thread Starter
Hyperactive Member
ya that worked..but i can't figure out the usage...it keeps saying argument not optional
-
Aug 13th, 2001, 07:24 PM
#7
Laugh, and the world laughs with you. Cry, and you just water down your vodka.
Take credit, not responsibility
-
Aug 13th, 2001, 07:28 PM
#8
Thread Starter
Hyperactive Member
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
-
Aug 13th, 2001, 07:30 PM
#9
Thread Starter
Hyperactive Member
even if i do
Private Sub Command2_Click()
ScrambleText
End Sub
it highlights it and says argument not optional..***
-
Aug 13th, 2001, 07:35 PM
#10
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|