Wednesday, 30 December 2009

A Note on Clearing Labels

When you start to build bigger applications you will maybe be populating a label or other controls multiple times with different values. Each time you finish the operation you will want to clear the form.

Generally what most coders do (What I have learned from looking at experienced coders coding) is that you will maybe create a sub to handle this clearing event. So to clear one form with three text fields and 2 labels you might call this:

'Do something
'End of operation
clearFields() << Call clear routine here

And the bit of code for this routine would look something like:

Private Sub clearFields()

txt1.text = ""
txt2.text = ""
txt3.text = ""
lbl1.text = ""
lbl2.text = ""

End Sub

For simplicity assume this code to be in the form class code.

No comments:

Post a Comment