-
I am learning VB6 as a hobby. I am trying to make a little
program that would solve the "jumble" words (i.e. like
the puzzles found in the newspaper). As the following
code indicates, the letters "otpoh" can be rearranged
to (eventually!) spell out the word "photo."
But my problem is that letters are used over and over
again! (For example, "oopo", etc.)A less serious problem
is that these five letters are not neatly divided into
words.
' Code that goes under the "Go" command...
Randomize Timer
For Counts = 1 To 3
scramword = "otpoh"
x = Int(Rnd(1) * 6)
Select Case x
Case Is = 1
Print Mid(scramword, 1, 1);
Case Is = 2
Print Mid(scramword, 2, 1);
Case Is = 3
Print Mid(scramword, 3, 1);
Case Is = 4
Print Mid(scramword, 4, 1);
Case Is = 5
Print Mid(scramword, 5, 1);
End Select
Can anyone help?
THANKS IN ADVANCE!
Richard G.
-
Code:
Function ScrambleWord(Aword As String) As String
Dim a() As Byte, x As Integer, temp As Byte, flipa As Integer, flipb As Integer
a = StrConv(Aword, vbFromUnicode)
For x = 0 To 20
flipa = Int(Rnd * Len(Aword))
flipb = Int(Rnd * Len(Aword))
temp = a(flipb)
a(flipb) = a(flipa)
a(flipa) = temp
Next x
ScrambleWord = StrConv(a, vbUnicode)
End Function
'to use
MsgBox ScrambleWord("otpoh")
[Edited by kedaman on 10-14-2000 at 01:59 PM]