kaf,
The UserSentence is capitalized and spaces added between punctuation and on the ends so that Hal's functions can recognize whole words.
Example sentence:
UserSentence = "GOODWILL TOWARDS MEN IS GOOD."
If Instr(1, UserSentence, "WILL", vbTextCompare) > 0 Then 'do something'
If Instr(1, UserSentence, " GOOD ", vbTextCompare) > 0 Then 'do something'
The first InStr() above will be true since it detects "WILL" within "GOODWILL", but that's not what we wanted. The second InStr() will not detect "GOOD.".
The proper method is:
UserSentence = " GOODWILL TOWARDS MEN IS GOOD . "
If Instr(1, UserSentence, " WILL ", vbTextCompare) > 0 Then 'do something'
If Instr(1, UserSentence, " GOOD ", vbTextCompare) > 0 Then 'do something'
The first InStr() above will be false since the whole word "WILL" is not present, that's what we wanted. The second InStr() will properly detect " GOOD " since their are spaces on both sides.
Before using functions like Len() or code like the following, it is good practice to use the Trim() function to make certain there aren't extra spaces lurking somewhere.
If Variable = "WILL" Then 'do something'
is better as
If Trim(Variable) = "WILL" Then 'do something'
If Variable equaled " WILL" the comparison would not have had equivalency due to the leading space. Trim() does not change the value of Variable, it just "trims" it for the comparison. To trim Variable you have to do:
Variable = Trim(Variable)
To replace Hal's name in a string with a space you could use:
UserSentence = Replace(UserSentence, ComputerName, " ", 1, -1, vbTextCompare)
No matter what you do remember that the GetResponse function has a function near the top that detects the presence of Hal's name and sets the BlockSave flag to block saving certain info. That affects whether Hal remembers something or not.
Have fun experimenting.
=vonsmith=