Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Visual Basic > VB.NET 1.0 > VB.NET 2002/2003 Basics
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
VB.NET 2002/2003 Basics For coders who are new to Visual Basic, working in .NET versions 2002 or 2003 (1.0 and 1.1).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB.NET 2002/2003 Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old November 9th, 2004, 01:29 PM
Registered User
 
Join Date: Nov 2004
Location: , KS, .
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to Doldrums Send a message via AIM to Doldrums Send a message via MSN to Doldrums Send a message via Yahoo to Doldrums
Default Imports with .VB files

I am working with a project called "Portal" with a namespace of "Portal" at C:\Projects\Portal.

I also have some classes in a file at C:\Projects\Globals\MyCode.vb.

The MyCode.vb looks some like:

namespace "MyCompany.Globals"
public class Hello

  Shared public Function() As String
    Return "Hello World"
  End Function
End Class

End Namespace

How would I use the MyCompany.Globals.Hello class in the Portals project?

I've tried Imports MyCompany.Globals, but it says it can not find the namespace. Any help would be greatly appreciated!

Hugh
Reply With Quote
  #2 (permalink)  
Old November 9th, 2004, 02:58 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , .
Posts: 540
Thanks: 0
Thanked 4 Times in 4 Posts
Default

Compile your MyCode project into a .dll if you haven't already. Then add a reference to it by right-clicking on "References" in Solution Explorer. Browse for the .dll and add it. It should then be listed under your references.

You should then be able to access it.

J
Reply With Quote
  #3 (permalink)  
Old November 9th, 2004, 03:41 PM
Registered User
 
Join Date: Nov 2004
Location: , KS, .
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to Doldrums Send a message via AIM to Doldrums Send a message via MSN to Doldrums Send a message via Yahoo to Doldrums
Default

So you have to compile it? There is no way to link to source code that isn't under the project's directory structure unless it is compiled?

If so, that sucks. I still want this code to be compiled into my project... just want it located somewhere so multiple projects can use it.

Doldrums
Reply With Quote
  #4 (permalink)  
Old November 9th, 2004, 04:32 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , .
Posts: 540
Thanks: 0
Thanked 4 Times in 4 Posts
Default

Quote:
quote:Originally posted by Doldrums


just want it located somewhere so multiple projects can use it.
That's basically what you would be doing. The compiled .dll file can be referenced from as many projects as you want. Note that you compile it in it's own project and then reference it externally from whatever project you want.

J
Reply With Quote
  #5 (permalink)  
Old November 10th, 2004, 10:01 AM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Doldrums-

The .NET model is to use references to other assemblies. The .NET runtime cannot use source code, it must use the compiled result (assembly). Perhaps you need to create a project to contain your global code. The solution for one individual project can contain that global code project as well as the application specific project. This you can do with as many solutions as you wish.
Reply With Quote
  #6 (permalink)  
Old November 10th, 2004, 10:56 AM
Registered User
 
Join Date: Nov 2004
Location: , KS, .
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to Doldrums Send a message via AIM to Doldrums Send a message via MSN to Doldrums Send a message via Yahoo to Doldrums
Default

I guess I'm not making myself totally clear.

I'm wanting to have my project use source code that is in a different directory and NOT in an assembly. Think of this as global code for all projects. I don't want this code to be in a separate DLL, I want it to be compiled into my current project's assembly.

I realize I can compile this code into a DLL, include it in my solution, and import it into my current project. That is not what I want to do. I want to have my VB project use .vb files that are located in a directory that is different that the current project's directory. I can't find a way to do this. Is it possible?
Reply With Quote
  #7 (permalink)  
Old November 11th, 2004, 09:58 AM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

No, not from what I know. Never actually tried it, but when you add a code file into a project the file lives in that project's directory. Are you using a source control system? Is so then I'll explain a technique to achieve what you want.
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
imports - Chapter 2 sfarber53 BOOK: Beginning Java 2 2 September 19th, 2010 07:43 PM
Excel Text Imports Revisited bph Access 5 April 1st, 2004 07:35 AM
how to make help files in VB ritesh_sinha VB How-To 3 March 24th, 2004 12:13 PM
Page 57 Imports Sytem.Web.UI martina68 BOOK: ASP.NET Website Programming Problem-Design-Solution 1 February 16th, 2004 12:28 PM
Help on ListBox imports text tdeng Beginning VB 6 2 December 22nd, 2003 02:46 PM



All times are GMT -4. The time now is 12:41 PM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.