|
-
Aug 2nd, 2005, 11:10 PM
#1
Thread Starter
Lively Member
how to make a function available for all forms ?
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 ??
-
Aug 2nd, 2005, 11:11 PM
#2
Member
Re: how to make a function available for all forms ?
Instead of this:
Code:
Private Sub Permission()
End Sub
This:
Code:
Public Sub Permission()
End Sub
-
Aug 2nd, 2005, 11:40 PM
#3
Re: how to make a function available for all forms ?
You must put it in a module though : )
-
Aug 2nd, 2005, 11:42 PM
#4
Re: how to make a function available for all forms ?
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
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Aug 2nd, 2005, 11:44 PM
#5
Re: how to make a function available for all forms ?
...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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|