Results 1 to 9 of 9

Thread: [RESOLVED] Imports

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2011
    Location
    Oregon City, Oregon
    Posts
    471

    Resolved [RESOLVED] Imports

    I use Visual Studio as my IDE and am currently learning visual basic from some tutorials. I currently have a project that has two files. One of them is a class file (Person) that contains a number of public subroutines and functions as well as some private variables. Additionally, I have a form file (frmPerson) that has the command, "Imports Person" in the first line.

    The form file is having no trouble calling the subroutines and functions in the class file, but there is an error that shows up in the Imports Person line and I get the following:

    Namespace or type in the Imports Person Doesn't contain any public members or cannot be found. Make sure that the Namespace or the type is defined and contains at least one public member. Make sure that the imported element name doesn't have any alias.

    I cannot see any evidence that I have any aliases that would cause this error and the class file indeed has public subroutines and functions. As for a Namespace am I supposed to include one in one of the files and if so, how is this done in VB?

    Any help would be appreciated as this is driving me crazy and I cannot find anything on this.

  2. #2

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2011
    Location
    Oregon City, Oregon
    Posts
    471

    Re: Imports

    Wouldn't you know that as soon as I ask for help I find the answer? It turns out that I needed to add the project name to the line and it should have been:

    Imports projectName.Person

  3. #3
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    7,450

    Re: Imports

    1-Please mark this thread as Resolved
    2-Although you say you are using VB (visual basic), I believe you are still using visual Basic 2010 (as seen in other posts).So, if you are NOT using Visual Basic 6, please post future questions/problems in the .NET section of this forum...this part is for Visual Basic 6 and Earlier.
    3-Have a great West Coast day!

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2011
    Location
    Oregon City, Oregon
    Posts
    471

    Re: [RESOLVED] Imports

    Done and done. Thanks.

  5. #5
    Super Moderator FunkyDexter's Avatar
    Join Date
    Apr 2005
    Location
    An obscure body in the SK system. The inhabitants call it Earth
    Posts
    7,612

    Re: [RESOLVED] Imports

    Moved
    You can depend upon the Americans to do the right thing. But only after they have exhausted every other possibility - Winston Churchill

    Hadoop actually sounds more like the way they greet each other in Yorkshire - Inferrd

  6. #6
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    35,242

    Re: [RESOLVED] Imports

    If you are still around, I'm curious as to why you are using that Imports statement anyways? I can't think of any advantage that it would confer.
    My usual boring signature: Nothing

  7. #7

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2011
    Location
    Oregon City, Oregon
    Posts
    471

    Re: [RESOLVED] Imports

    I am going through some tutorials (VB is new to me) and that is what they were using. I have since learned of better ways, like Namespaces, to achieve the same end.

    GW

  8. #8
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    35,242

    Re: [RESOLVED] Imports

    I was thinking they might have suggested that, since you did mention the tutorials. Did they say why? Others might have different opinions, but I see no reason to import a class that was written in the same project. If the other class is in a dll, that would be different, but it sounds like this class is just in a different code file in the same project. That should mean that the import statement does nothing at all, so I'm wondering why they would even suggest it?
    My usual boring signature: Nothing

  9. #9

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2011
    Location
    Oregon City, Oregon
    Posts
    471

    Re: [RESOLVED] Imports

    I actually think it was just handy and he was just taking a look at an alternative approach. However, he gave no explanation as to why, but hasn't used that since. Everything else has been Namespace holding a super class with additional inheritance classes. But good to know what the usage of that is actually supposed to be. Also, you are right, because I tried it later without the import and it worked just fine. No telling what was the purpose. These are Bucky tutorials on VB if you care to take a look. I am finding them quite helpful overall.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width