Please Please Urgent help

  • Thread starter Thread starter Dib
  • Start date Start date
D

Dib

Hi,
I have this code that seems to work ok, but not quite good. What I am
trying to do is if the user enters abc it changes it to "This is a test",
but my code finds the word abc on the first line and changes that, if I have
abc on the 3rd line it does not change. I can get this to work if the user
high-light the word to change and hit the space Bar, I am trying to find out
if there is a way to high-light the word the user have typed. I am able to
get the word the user has entered but I cannot get it to High-light the word
.. I am using Rich text box. This is kind of an Auto-correct.

thanks Dib

If KeyCode = 9 Then ' TAB key was pressed.
' Ignore the TAB key, so focus doesn't
' leave the control
KeyCode = 0
' Replace selected text with the tab character
Rrtf.SelText = vbTab
End If


With Keyrs
.MoveLast
k = .RecordCount

.MoveFirst
If KeyCode <> 32 Then

For m = 1 To k
If !strKeycode = KeyCode Then
'If .NoMatch = False Then
strRep = strRep & Keyrs!strchar
Exit Sub
End If
.MoveNext
Next
End If
End With
strRep holds the value the user has entered. I tried applying it the thr
Rrtf but .....

If KeyCode = 32 Then
With rs
Do Until .EOF
If !strReplace = Rrtf.SelText Then , this way works fine, but I
need the program to high-light the word instead of the user.
' strToFind = strRep 'rs!strreplace
' If Len(Rrtf.Text) = 0 Then Exit Sub
' If Rrtf.SelLength > 0 Then Rrtf.SelLength = 0
' If Len(strToFind) = 0 Then Exit Sub
' intFoundPos = Rrtf.Find(strToFind, , , rtfWholeWord) ' this one
here only find the first word and replaces only that word, not a good idea
Rrtf.SelText = rs!strwith
Me.AbstractNotes.SetFocus
Exit Do
End If
rs.MoveNext
Loop

End With
End If
rs.Close
Set rs = Nothing
strRep = ""
End Sub
 
Back
Top