Last post Dec 09, 2008 05:31 PM by DkUltra
Dec 04, 2008 10:52 AM|Lorddog|LINK
I am working on a project which is in a folder of an outer project that I have no control over or access to.(the outer is actually done in c# too whereas I am using vb.net)
so I dont have access to global folders, global files. I have been using user controls for things that are happening on multiple pages that use the same code. for instance I have 6 main sections in 6 folders and each section has a news page. I made 1 user
control that you set the section of and it does the news for that section. Thus I have all my news code in 1 file.
anyhow I have a few processes (functions) that I dont want to duplicate in several files and would like to have those functions in 1 place for easy management.
what is a proper way to do this? do I make my own class and import it? what is the imports syntax for that?
Dec 04, 2008 11:06 AM|jgangwisch|LINK
if you want a function that is global for your whole program. Just make a function like this:
Public Shared Function MyFunction(byval myarg as integer)
The imports function is for namespaces. For instance
Public Function MyFunction(byval myarg as integer)
Then in code you code
imports MyGlobal and use MyFunction anywhere that it is imported
Dec 04, 2008 11:35 AM|Lorddog|LINK
not sure how my imports would know where MyGlobal is located. again I am under the constraints that I have no access to the global folders, web.config or any other global entites. And also I cannot make this auto-global because that might conflict with the
outer project (which I actually know nothing about and have no access to). I need a way to specify a local include file or class of functions.
right now I have to copy my functions into each file that uses them. duplicate copies means harder to maintain but at least that works.
Dec 09, 2008 05:31 PM|DkUltra|LINK
The simplest way is to add a module to the project
and to create a public shared function or sub in the module
no imports needed then
<Runtime.CompilerServices.CompilerGlobalScope()> function attribute
Hope this helps