[AccessD] Doin the class thing - frmDNDText

John W Colby jwcolby at gmail.com
Thu Feb 7 09:29:48 CST 2013


The code for the form's class is simple.  In the form's header we create an instance of the class 
for every text box we want to handle.  Notice that I already have a disclaimer that this is the 
'quick and dirty' way of doing things.  This works but there is a better way which we will discuss 
once you have absorbed this method.

'
'The quick and dirty way to do this
'
Private cDNDTxt2 As clsDNDText
Private cDNDTxt4 As clsDNDText
Private cDNDTxt6 As clsDNDText

In the form's Open event we initialize each of the instances of this class, setting the pointer to 
each instance using the new keyword and then passing in a pointer to one of the text boxes in the 
mInit method.

Private Sub Form_Open(Cancel As Integer)
     Set cDNDTxt2 = New clsDNDText
     cDNDTxt2.mInit Text2

     Set cDNDTxt4 = New clsDNDText
     cDNDTxt4.mInit Text4

     Set cDNDTxt6 = New clsDNDText
     cDNDTxt6.mInit Text6

End Sub

and finally, not included in the original post we want to cleanup in the form's close event

Private Sub Form_Close()
     Set cDNDTxt2 = Nothing
     Set cDNDTxt4 = Nothing
     Set cDNDTxt6 = Nothing
End Sub

How much simpler can it be?

Let's discuss this and then we can move on to the next step.

-- 
John W. Colby

Reality is what refuses to go away
when you do not believe in it



More information about the AccessD mailing list