Files
Public vs Dim declaration example
Code
Modules: private_vs_public_vs_dim1
'This allows for testing of Public, Private, and Dim variables
'Written by Keith Rice
'CADSharp LLC
'www.cadsharp.com
Dim swApp As SldWorks.SldWorks
Public swModel As SldWorks.ModelDoc2
Sub main()
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Call anotherSub
End Sub
Sub anotherSub()
Call aSubInAnotherModule
End Sub
'If you declare something inside of a sub procedure, it is only available in that sub proc.
'If you declare something with Dim outside of the sub procedure, it is available in all _
sub proc's.
'If you declare something with Public outside of the sub proc, it is available in all _
modules or forms.
'Proof: create the above scenarios, and then type "swmodel." within another sub or module _
and see if the intellisense is available.
Modules: another_module
Sub aSubInAnotherModule()
Debug.Print swModel.GetTitle
End Sub
Forms: UserForms1
Private Sub UserForm_Click()
End Sub