Hi on one form i have lots reasons to call the same bit code i.e. from different buttons or key presses. Rather than write the code over and over again i would like to know how to write the code once and then call it when needed. Thanks in advance
All functions and sub's are public by default. You can optionally put the Public keyword in front of it, or use the Private keyword to keep it local to the particular form or module it is in.
Just wanted to note also that to call a public function from code, instead of putting this code into the Click event of the command button:
Code:
Private Sub cmdButton_Click()
fTest
End Sub
and then putting the code into the Click event of the command button, it's just as easy to simply put: