By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,851 Members | 1,374 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,851 IT Pros & Developers. It's quick & easy.

Referencing Forms

P: n/a
Hey..

I was just wondering why there are so many ways to reference a form and
what are the pros and cons of using each.

I've seen at least 5 different ways, which is correct (or in what
situations are each most correct)?

Private Sub cmdButton_Click()
' This causes the same MsgBox to be displayed 10 times in A2K
' Line 9 has the added bonus of referencing form-specific controls
' from IntelliSense, the rest (well, the ones w/ the dot)give
' generic form props/meths

1 MsgBox Forms(0).Text0
2 MsgBox Forms(0)!Text0

3 MsgBox Forms("form1").Text0
4 MsgBox Forms("form1")!Text0

5 MsgBox Forms.form1.Text0
6 MsgBox Forms.form1!Text0

7 MsgBox Forms!form1.Text0
8 MsgBox Forms!form1!Text0

9 MsgBox Form_Form1.Text0
10 MsgBox Form_Form1!Text0

End Sub

Nov 13 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
I like consistency.
I use the dot, never the bang.
My forms always have code behind them.
The form object is public and accessible, regardless of its use.
The form object can be instantiated multiple times by creating an array
whose elements are instances of it: DimSomeForms(3) as Form_Form1.
The form object is always available; referring to it, opens it (if it
is not already open).
Public Properties of the form object are referred to and used just like
any other Properties.

I always use #9: Form_Form1.Text0.

Nov 13 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.