<Unable to duplicate? Really? [etc.]
Note for metatags:
[brit] Responses in British. Please understand that British is a second language for the writer.
[amer] Responses in American.
Language not contained in either should be mutually intelligible.
[brit]
strongm, though with your unusually acute capabilities you may be able to show otherwise, my own not inconsiderable experience reveals that the three lines of code that I used are substantively identical to the three lines of code that both you and Mr Davies used. That given, it follows that I did indeed correctly, and upon first attempt, grasp, not to mention implement and test, the concept that both Mr Davies' and your clarifying post were attempting to convey. Permit me therefore (with all necessary apologies for being annoying and inconvenient) to repeat that my results indeed vary from the results described, and add that they appear to do so for reasons other than my lack of understanding of the concept put forth.
Now, strongm, you will of course make free to point out any difference the light of your superior capabilities may reveal between the three lines of code herein set forth and the three lines of code that you provide, that would in and of itself account for the variance in behavior. Of course, if you do indeed find such a difference, one must observe that such a finding would constitute a workaround to the difficulty at hand, upon which one has stumbled, albeit inadvertently, and one will accept in advance your thanks.
[/brit]
[amer]
Daggone, strongm, I think I know how to write 3 trivial lines of code without screwing it up! Here's the code I wrote ahead of your post, without any help from you. And get this: my shiny new Form2 does indeed unload, or at least disappear from any context available to the VB development environment, and furthermore, no new instances of the form are created. Now, if you find something "wrong" with my code, I'd say I've fixed the version you provided, since mine works and yours doesn't, and I guess you can thank me for it.
[/amer]
[brit]Right. We've had our little diversion, one will assume not at strongm's expense, so let us now focus on the topic in question.[/brit][amer]All right, that was all kinds of fun, and I figure strongm's skin is thick enough that his nose hasn't gotten out of joint. Now let's get down to business.[/amer] Here's the code I used.
Form1:
Code:
Private Sub RichTextBox1_Click()
Dim cForm As New Form2
cForm.Show vbModal
End Sub
Form2:
Code:
Private Sub Command1_Click()
Unload Me
End Sub
strongm, taking your "click anywhere you like" directive literally yields the following data on my machine:
1. Clicking on form2's command button closes the form. Clicking again on the rich text box opens it again. Clicking anywhere else on form2 (with the exception of the controls in the top right corner, which behave as expected) has no effect. Behavior repeatable.
2. Clicking anywhere on form1 causes the title bar on form2 to flicker 3 times, as if it were being made the current form and then not the current form, and then the current form. (Not having sound capability on my current machine, I can't say if the bell rings or not.)
3.
Clicking the rtb, closing the modal form, and repeating the process causes the form's position to change on the screen, in the manner of overlapping MDI child forms. This was the most interesting thing I found, so I bolded it. Perhaps phantom instances are running around?
Conclusion: although the behavior is buggy, I'm unable to duplicate the described behavior.
If I can provide further information or do more arcane tests on my platform at your direction, please advise.
For the record, I get the same behavior with no SP and with SP6.
Bob