# Visual Basic "Imports" Statement

**URL:** <https://boards.straightdope.com/t/visual-basic-imports-statement/388146>\
**Category:** Factual Questions\
**Created:** [January 16, 2007, 2:17am UTC](https://boards.straightdope.com/t/visual-basic-imports-statement/388146 "2007-01-16T02:17:01Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![DanBlather](https://avatars.discourse-cdn.com/v4/letter/d/f4b2a3/32.png) [@DanBlather](https://boards.straightdope.com/u/DanBlather)\
**Post date:** [January 16, 2007, 2:17am UTC](https://boards.straightdope.com/t/visual-basic-imports-statement/388146/1 "2007-01-16T02:17:01Z")

</div>

I have learned Cobol, RPG, Fortran, Basic, PL/1, Pascal, C, and Modula 1, but Visual Basic is driving me nuts. There is just so much there and the documentation is overwhelming yet incomplete.

I have a DLL that I got from a HW vendor. In another VB project I just put it (foo.dll) in the same directory as the .sln file and used an Imports statement: “Imports foo”. That worked fine. I have another, slightly more complicated program and the build is complaining that it can’t find the file. I have it in the directory that contains the new .sln file just as I did for the other program; i.e., “Visual Studio 2005\Projects  
ame\_of\_program”. Serach as I might through the documentation I can’t find anything that describes the search path for Imports. What am I doing wrong?

---

<div class="post-metadata">

**Author:** ![DMC](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/dmc/32/18049_2.png) [@DMC](https://boards.straightdope.com/u/DMC)\
**Post date:** [January 16, 2007, 3:12am UTC](https://boards.straightdope.com/t/visual-basic-imports-statement/388146/2 "2007-01-16T03:12:59Z")

</div>

It has been a VERY long time (beta 2, to be exact, as I’m pure SQL these days), but there are a couple of things to look at.

First, if memory serves, imports was just so that you didn’t have to fully qualify every call to various objects. In other words, if you wanted to use a class named “Baseball”, and it was in the “System.Games.Sports” namespace, using Imports with the namespace allowed you to call “Baseball” without using the syntax System.Games.Sports.Baseball everywhere.

To actually use a .dll in your app, you had to add a reference to it, which usually required it to be registered (using regsvr32 or the like), then added as a reference to your project under the Project menu. Once you had the reference, you could use Imports for it’s namespaces just as you would for the built in variety.

As I said, it’s been forever, but perhaps that will either help you down the correct path, or get you started while waiting for a current .NET type to wander in.

---

<div class="post-metadata">

**Author:** ![RaftPeople](https://avatars.discourse-cdn.com/v4/letter/r/6f9a4e/32.png) [@RaftPeople](https://boards.straightdope.com/u/RaftPeople)\
**Post date:** [January 16, 2007, 3:14am UTC](https://boards.straightdope.com/t/visual-basic-imports-statement/388146/3 "2007-01-16T03:14:52Z")

</div>

I don’t have an answer, but I do have a tip: Google is your friend for any technical issues.

Often I will key in the exact error text (minus my own file names) plus maybe a word or 2 for context (visual studio, etc.) and I typically find the answer on the first page or 2.

---

<div class="post-metadata">

**Author:** ![Khadaji](https://avatars.discourse-cdn.com/v4/letter/k/9e8a1a/32.png) [@Khadaji](https://boards.straightdope.com/u/Khadaji)\
**Post date:** [January 16, 2007, 11:18am UTC](https://boards.straightdope.com/t/visual-basic-imports-statement/388146/4 "2007-01-16T11:18:39Z")

</div>

I don’t use VB, but I do use Visual Studio. VS will often put the executables in different folders, depending on the type of build. Debug and Release often get their own folders and that is where the exe is running from, so putting the dll in the same folder as the sln file may not be enough. Find where the EXEs are formed and put the dll there. Conversely, you should be able to get away with putting it in \Windows\System or \Windows\System32

---

<div class="post-metadata">

**Author:** ![FRDE](https://avatars.discourse-cdn.com/v4/letter/f/e68b1a/32.png) [@FRDE](https://boards.straightdope.com/u/FRDE)\
**Post date:** [January 16, 2007, 11:32am UTC](https://boards.straightdope.com/t/visual-basic-imports-statement/388146/5 "2007-01-16T11:32:13Z")

</div>

Probably better to ask in a dotnet Newsgroup

For the microsoft news server, try these newsgroups…

news://msnews.microsoft.com/microsoft.public.dotnet.general  
news://msnews.microsoft.com/microsoft.public.dotnet.languages.vb  
news://msnews.microsoft.com/microsoft.public.vsnet.general  
news://msnews.microsoft.com/microsoft.public.vstudio.general  
news://msnews.microsoft.com/microsoft.public.vstudio.setup  
news://msnews.microsoft.public.dotnet.languages.vb.upgrade  
news://msnews.microsoft.public.dotnet.languages.vb.controls  
news://msnews.microsoft.public.dotnet.languages.vb.data

---

<div class="post-metadata">

**Author:** ![Clothahump](https://avatars.discourse-cdn.com/v4/letter/c/51bf81/32.png) [@Clothahump](https://boards.straightdope.com/u/Clothahump)\
**Post date:** [January 16, 2007, 3:41pm UTC](https://boards.straightdope.com/t/visual-basic-imports-statement/388146/6 "2007-01-16T15:41:44Z")

</div>

I would set a reference to the DLL rather than use Imports.

---

<div class="post-metadata">

**Author:** ![DanBlather](https://avatars.discourse-cdn.com/v4/letter/d/f4b2a3/32.png) [@DanBlather](https://boards.straightdope.com/u/DanBlather)\
**Post date:** [January 16, 2007, 4:36pm UTC](https://boards.straightdope.com/t/visual-basic-imports-statement/388146/7 "2007-01-16T16:36:52Z")

</div>

Thanks for all the pointers everyone. It tured out that I needed to add a reference to the DLL and still use the Imports to get the declarations. I have been copying the same program over and over, and when I did one from scratch I forgot what I did the first time a few months ago.
