testoing is easy i wanna make em
ive got plenty of code
and using it in a database it workls though only with two words rihght now
to got
to hot
im i
at a
code;
Option Compare Database
Private Sub Command1_Click()
maxTries = 0
'maxTries = InputBox("Enter number of word combinations to try.", "Enter Number", , Form1.Top + 300, Form1.Left + 100)
maxTries = InputBox("howmany lopps")
'Text1.Visible = False 'hide final word box
'Command3.Visible = False 'hide load list button
blnCorrect = False 'word is no good
blnHALT = False 'set halt boolean to allow loops
For cow = 1 To maxTries 'entered by the user
For z = 1 To 30 '_______________
strletterA(z) = "" 'erase all
strletterB(z) = "" 'letters
Next z '----------------
z = 1 'reset variable
strword = "": str1stHalf = "": str2ndHalf = ""
strdirtyword = "" 'Clean important word strings
'*******
LoadWord 'duh...
'*******
'get rid of the spaces that shouldnt exist anyway
strdirtyword = Trim(strdirtyword)
'****************************************************
'IGNORE
If intloop = 10000 Then
intloop = intloop 'set stop here
'useless code for debug stop
End If
'*************************************************
'remove spaces and any non letter characters
For z = 1 To Len(strdirtyword)
'pull one letter at a time and check
strtempletter = Mid(strdirtyword, z, 1)
'next line for debug purposes
'Text2.Text = Asc(strtempletter)
'if the characters "ok" add it to "clean" string
If Asc(strtempletter) > 96 And Asc(strtempletter) < 124 Then
strword = strword & strtempletter
Else
strtempletter = "" ' clean if not
End If
Next z
z = 1 'reset variable
'begin work
v = Len(strword) 'save integer for extarction calc.
'extract halves
If v / 2 = Int(v / 2) Then
'if the rounded value
'and orig. are = then
'words even...
str1stHalf = Left(strword, v / 2)
str2ndHalf = Right(strword, v / 2)
Else
'odd word
'this may be flawed....
str1stHalf = Left(strword, (Int(v / 2))) 'might round up (bad)
str2ndHalf = Right(strword, (Int(v / 2)))
End If
'*************************************
'Reverse 2nd half to mirror first
str2ndHalf = StrReverse(str2ndHalf)
'works
'**************************************
'extract letters
For x = 1 To Len(str1stHalf)
'save each to array
strletterA(x) = Mid(str1stHalf, x, 1)
strletterB(x) = Mid(str2ndHalf, x, 1)
Next x
'check letters
For y = 1 To Len(str1stHalf)
If strletterA(y) = strletterB(y) Then
blnCorrect = True
Else
blnCorrect = False
Exit For
End If
Next y
If blnCorrect = True Then
saveword 'store in array to print
End If
Next cow
Text1 = strdirtyword 'show last combo
'Text1.Visible = True
'Command4.Visible = False
' Command3.Visible = False
With Command2
.Visible = True
.Caption = "Try Another"
End With
If L = 0 Then
Label4.Caption = "sorry no luck, " & cow & " Tries."
Else
'notify off succcess
Label4.Caption = "Log Printed to file!, " & L & " successes."
End If
'give em the fireworks
Label4.Visible = True
End Sub
Private Sub Command2_Click()
'try again button resets
'Text1.Visible = True
'Text1 = ""
'Image1.Visible = False
Label4.Visible = False
Label4.Caption = ""
Command1.SetFocus
Command2.Visible = False
Command1.Visible = True
L = 1
End Sub
Private Sub Command3_Click()
'load list
Form1.Hide
Form2.Show
End Sub
Private Sub Form_Load()
Command1.Caption = "Click to Decode"
L = 0 ' number of words found
End Sub
module called
Option Compare Database
Public varwordnumber As Integer
Public maxcount, logprint As Integer
Public maxTries, intloops As Long
Public varword As String
Public strdirtyword, strword, str1stHalf, str2ndHalf, strtempletter As String
Public v, x, y, z, T, L As Integer
Public strletterA(1 To 50) As String
Public strletterB(1 To 50) As String
Public blnCorrect As Boolean
Public strwhatchama(1 To 500) As String
Public blnHALT As Boolean
Public Sub LoadWord()
'declare database,recordset,and variables
Dim db As Database
Dim rec As Recordset
Dim intRecords As Integer
Set db = CurrentDb()
'set upper bound record, not to exceed
Set rec = db.OpenRecordset("words")
intRecords = rec.RecordCount
'move to first record, although should be default...safety first
'GENERATES RANDOM NUMBER WHICH WILL CHOOSE WORD FROM LIST
Randomize
'loop through records finding case number
For T = 1 To 2 ' numbr of words to join
varwordnumber = Int(Rnd * intRecords) + 1
rec.MoveFirst
For x = 1 To intRecords
If x = varwordnumber Then
varword = rec![word] 'save to temp
strdirtyword = strdirtyword & varword & " "
Else
rec.MoveNext
End If ''add to joined string with spaces
Next x
Next T
x = 1
rec.Close
End Sub
Public Sub saveword()
L = L + 1
strwhatchama(L) = strdirtyword
'strwhatchama(L) = strword
Dim db As Database
Dim rec As Recordset
Dim intRecords As Integer
Dim strIndex As String
Set db = CurrentDb()
Set rec = db.OpenRecordset("palindromes")
With rec
.AddNew
![palindromes] = strwhatchama(L)
.Update
End With
rec.Close
End Sub