'simply copy this code behind a command button on a form and also add a textbox 'to the form
'this function will determine whether the word you type into a textbox on the 'form is a palendrome or not after you click the command button
'a palendrome is word such as "pop" or "level" which spells the same forwards 'as backwards
'declare variables
Dim strWord As String
Dim strReverse As String
Dim i As Integer
strWord = Text1.Text
For i = Len(strWord) To 1 Step -1
strReverse = strReverse & Mid$(strWord, i, 1)
Next i
If UCase(strReverse) = UCase(strWord) Then
MsgBox "This IS a palendrome.", vbExclamation = vbOKOnly, "Yes Indeed"
Beep
Exit Sub
Else
MsgBox "This IS NOT a palendrome.", vbCritical = vbOKOnly, "Sorry"
End If
|