|
-
January 26th, 2004, 11:58 PM
#1
How do you add a global import to the code?
I am coding in Visual Basic .NET and I am trying to code a global import. Can anyone help me with the proper syntax to use in the code? Maybe even provide a sample code for demo purposes?
Thanks
-
January 27th, 2004, 03:11 AM
#2
no global import
'global import' is the 'reference'. The 'Imports' keyword is file-based, the only way to make it work for all of your code parts is to put in a .vb file ALL of your modules, classes etc. (1)
Another way is to Import your public library in a module and then make inherited classes with no-addons from the sources, or just public subs/functions in which you can use their functionality with only the sub's names, without referencing to the whole lib name. (2)
Code:
'(1) ".vb filename=myEntireProjectInAvbFile.vb"
Imports libGlobalLibrary
Public Class Form1 'the startup form must be at the top of the file
...
End Class
Public Module Module1
...
End Module
Public Structure IntegerPlus
...
End Structure
'(2)=make lib's functionality public through public functions
'put this in a standard module (.vb file)
Imports libGlobalLibrary
Public Function GetNewInstanceOfMyClass1() As MyClass1
Return New MyClass1
End Function
'but you have to deal with it as an Object outside this module, unless if you use:
'Private cls1 As libGlobalLibrary.MyClass1 = GetNewInstanceOfMyClass1() 'I dont like that idea
'better to make Public instances, if you will going to need less than two instances of each of your classes
Public cls1globalInstance As New MyClass1 'it is accesible from all of your vb modules
...
There may be more ideas, I hope this will do for now.
Last edited by dtv; January 27th, 2004 at 03:19 AM.
- Better live in the digital world -
-
January 27th, 2004, 10:25 PM
#3
Thanks for info on the global import it helped!!!
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
|