Form Objects
Another way to create COM objects is with forms. You insert a new form into your project and Visual Basic automatically generates something equivalent to the following:
Dim Form1 As New Form1
Like any competent programmer, the first thing you do is go to the Name field of the property page and change the Name property from Form1 to a real name such as FStoryDialog. Visual Basic automatically changes the hidden statement to the following:
Dim FStoryDialog As New FStoryDialog
If you follow my advice, you won’t use this weirdly named object variable. Instead, you’ll define your own sensible name like this:
Dim dlgStory As FStoryDialog
Set dlgStory = New FStoryDialog
dlgStory.TaleLength = “Tall”
dlgStory.Show vbModal
This way, you specifically control form creation rather than having it done behind your back by hidden statements. But what happens to that FStoryDialog object variable created by Visual Basic? Check the last section where we discussed how New in declarations works. The FStoryDialog object variable is set to Nothing, but if you never use it, no form object is ever created for it.