Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: Visual Basic
Expertise: Intermediate
Sep 28, 1998

Avoid Form Confusion

When you define a form named MyForm, Visual Basic creates one instance with the name "MyForm." Many programmers confuse this special instance with other instances created using Dim. For example, the Caption statement in this code sets the caption on the automatically created instance. When the instance FRM appears, its caption is not set:

 Dim frm As New MyForm
	MyForm.Caption = "This is the single instance"
	frm.Show

Even more confusing problems can arise if you use MyForm within the MyForm code module, when an instance such as FRM might accidentally set properties on the automatically created form rather than itself. For this reason, never use MyForm within the MyForm code module.

Rod Stephens
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date