Rob,
I am trying to modify your code so that it executes in th
textbox1_change event. Let me explain.
I am trying to get it so that if the user enters a word in textbox
that is not in the dictionary, then a message comes up "word not i
dictionary" and then the word is parsed into individual letters an
placed back into the textbox as the person types.
I am not having much success so far. There are several problems t
overcome. The first is that I don't know how to add text into
textbox that already contains sub-strings....if I set textbox.value
str(1), then all the previous text is overwritten by the new value.
have tried using the clipboard as a temporary repository for th
existing text, then paste it back and add-on the sub-strings, but
have not been successful with that either.
Second, the str = Split(TextBox1.Text, " ") command acts different whe
in the textbox1_change event. The code seems to trigger whenever an
two sub-strings are joined together (e.g. try typing "the" and the cod
does not find "th" in the dictionary.) It needs to check for th
string using the " " delimiter. Thus, the code should not check to se
if the word is in the dictionary until the space bar is pressed...t
add a level of complexity here, " " is necessarily in the dictonar
itself as a "word". (e.g. the space character is assigned its own
digit code number.)
To reproduce what I have, I typed in separate cells in a vertica
column: "the", "quick", "brown", "fox", "a", "b", "c", ... "z", "".
(*** Note the space character). I then named this range "dictionary")
I have userform3 code as follows:
_________________________________________________
Private Sub CommandButton1_Click()
Dim str() As String
Dim i As Long, k As Long
str = Split(TextBox1.Text, " ")
k = 1
For i = LBound(str) To UBound(str)
Sheet1.Cells(k, 1).Value = str(i)
k = k + 1
Next
UserForm3.Hide
End Sub
Private Sub TextBox1_Change()
Dim str() As String, strTemp As String
Dim lngIndex As Long, i As Long, j As Long, k As Long
str = Split(TextBox1.Text, " ")
k = 1
On Error Resume Next
For i = LBound(str) To UBound(str)
lngIndex = Application.VLookup(str(i), Range("Dictionary"), 2, False)
If Err.Number Then
Err.Clear
UserForm3.TextBox1.Copy
MsgBox "Word not in dictionary: '" & str(i) & "' ;Parse Required."
For j = 1 To Len(str(i))
strTemp = Mid(str(i), j, 1)
lngIndex = Application.VLookup(strTemp, Range("Dictionary"), 2, False)
If Err.Number Then
Err.Clear
MsgBox "letter not in dictionary: " & strTemp
Else
'
' requirements:
' needs to (1) erase the word not in dictionary from the textbox
'leaving the rest of the text in place,
' (2) parse the word into individual letters with a space between
' each letter and a space at the end, (3) needs to insert this
' new string in the textbox in the place where the word-not-in
' -dictonary existed, and
' (4) allows the user to continue typing his or her paragraph
'
UserForm3.TextBox1.Value = strTemp
k = k + 1
End If
Next
End If
Next
End Su
--
Message posted from
http://www.ExcelForum.com