Hi ,
i have defined a sub called permission,
i want to make it global over the whole project, so in any form i can write
it will call it without defining it in every form, do i have to make global ??VB Code:
call permission
Printable View
Hi ,
i have defined a sub called permission,
i want to make it global over the whole project, so in any form i can write
it will call it without defining it in every form, do i have to make global ??VB Code:
call permission
Instead of this:
This:Code:Private Sub Permission()
End Sub
Code:Public Sub Permission()
End Sub
You must put it in a module though : )
Almost but you need to declare it only once in a standard Module because if you do it that way you need to reference it by calling the form name first.
Call Form2.Permission
Vs Call Permission
VB Code:
'In a module (Module1.bas) Option Explicit Public Function Pemission() MsgBox "I am in a Module that can be called from anywhere throughout this project! D" End Sub 'Behind any form in your project. 'Invoke from any procedure but for ex. its a command button click Option Explicit Private Sub Command1_Click() Call Permissions End Sub
...and the proper place for that sub is in a code module and not a form. Subs created in a code module are public by default and while if the sub is in Form1 you would have to call Form1.Permission from Form2, if it's in the code module you just have to do Call Permission, or simply Permission.