I am writing a program to quiz General Chemistry students on some properties of compounds, ions, and elements. One of those properties is the formula of the substance. As the student types the formula into a RichMemo ("rmInput" in the attached project), it is formatted automatically. If that answer is incorrect, the correct answer is shown in another RichMemo, "rmCorrectAnswers". Occasionally there is more than one acceptable answer to a question, so those answers are shown as a list in rmCorrectAnswers. I've gotten most of this worked out, but there are some problems. I've attached a small project illustrating what I'm trying to do. (The project is not the quiz - there are no questions or evaluation. The top RichMemo is the self-formatting answer input control; the bottom one shows the "correct" answers. The various kinds of answers in the quiz can be seen by commenting/uncommenting the appropriate sections in the MakeAnswerList procedure. "Hybridization" is included for completeness. I think I've gotten all the bugs worked out for that.)
Some formulas contain a "hydrate dot", a heavy dot centered vertically on the line, directly after which numbers are written normally (ie, not subscripted). The dot is entered by typing a period, which should then be replaced by the dot. For example, typing FeCl3.6H2O should result in only the 3 and 2 being subscripted and the period should appear as the dot. I've tried several ways to introduce the dot, shown in the source code as comments. Usually the replacement does not occur; when it does, the other formatting gets messed up. Also, the formatting in the two RichMemos is sometimes different, even though they both use FormatFormula. So:
1. How can I incorporate the hydrate dot into the formulas?
2. Can I save the resulting string (the basic string, not the rtf) in a simple text file, or would I have to convert the dot back to a period first? (And how would I do that?)
Other problems involve only rmCorrectAnswers:
3. The last line is always followed by an empty line. How can I remove it? (And why isn't it a problem in rmInput?) It doesn't present a problem in displaying the answer(s), really. But it feels awkward and unnecessary.
4. How can I adjust the height of the RichMemo according to the number of answers it holds? Because of space limitations on the form in the actual program, there should be a maximum of 4 answers showing. (See the end of the ShowAnswers procedure.) I've guessed at numbers for LineHeight and the small extra space I've added between the first two lines. I can refine those guesses, but there must be a way to actually measure them.
5. If a line is wider than rmCorrectAnswers's width the horizontal scrollbar appears, obscurring the last line. Is there a way to detect when this happens and to determine the scrollbar's height so I can adjust the height of rmCorrectAnswers? (See the "Plain text" section of MakeAnswerList. Actually, this should happen very seldom, if ever. But I am curious.)
6. (Trivial) When the vertical scroll bar appears, the first click on the downward scroll arrow works as expected, but the second click has only a tiny effect. All subsequent clicks work fine. This certainly doesn't have to be fixed, but, again, I'm curious as to the reason.
Finally, I apologize for asking so many questions in a single post. If I should have separated the questions, please let me know.
Thanks for your help.