Juggler_IN
Active Member
- Joined
- Nov 19, 2014
- Messages
- 358
- Office Version
- 2003 or older
- Platform
- Windows
I am unable to retain the position of a punctuation in the text while performing Cambridge Transposition (which scrambles every word in the string except the first and last). The reference code is:
Code:
Sub v(strText)
m = 1: Z = Split(strText, " "): j = UBound(Z)
For u = 0 To j
t = Split(StrConv(Z(u), 64), Chr(0)): w = UBound(t) - 1: l = Asc(t(w)): If l < 64 Or (l > 90 And l < 97) Or l > 122 Then e = t(w): w = w - 1 Else e = ""
If w > 3 Then
n = t(0): p = w - 1: S = ""
For i = -p To -1
S = t(-i) & S
Next
f = t(w)
For p = 1 To p - 1
r = Int((w - p) * Rnd()) + 1: n = n & Mid(S, r, 1): S = Left(S, r - 1) & Right(S, w - p - r)
Next
n = n & S
Else
n = Z(u): f = "": e = ""
End If
d = d & n & f & e & " "
Next
strText = d
End Sub
Sub Test()
strTestString = "This is a test."
v strTestString
Debug.Print strTestString
st = "According to a researcher at Cambridge University, it doesn't matter in what order the letters in a word are, the only important thing is that the first and last letter be at the right place. The rest can be a total mess and you can still read it without problem. This is because the human mind does not read every letter by itself but the word as a whole."
v st
Debug.Print strTestString
End Sub