Results 1 to 5 of 5

Thread: Compile error variable not found

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2021
    Posts
    1

    Lightbulb Compile error variable not found

    My project when I want to compile it will tells me compile error variable not defined.

  2. #2
    Fanatic Member Delaney's Avatar
    Join Date
    Nov 2019
    Location
    Paris, France
    Posts
    642

    Re: Compile error variable not found

    The codebank forum is made for sharing code with other people, not to post a question about a problem. I asked the moderators to move you thread.

    Beside that we need more information if you want some help : post the complete error message and the code that provoke the error and a clear explanation of the problem.
    Last edited by Delaney; Mar 15th, 2021 at 08:09 AM.
    The best friend of any programmer is a search engine
    "Don't wish it was easier, wish you were better. Don't wish for less problems, wish for more skills. Don't wish for less challenges, wish for more wisdom" (J. Rohn)

  3. #3
    Sinecure devotee
    Join Date
    Aug 2013
    Location
    Southern Tier NY
    Posts
    6,301

    Re: Compile error variable not found

    Quote Originally Posted by Somuchluv View Post
    My project when I want to compile it will tells me compile error variable not defined.
    Well that at least sounds good in that you must have Option Explicit turned on so you have to declare all your variables, and the error is telling you that at some line of code you are referring to a variable that is not available from that location.

    When you declare a variable, the code that can refer to that variable can be limited, which is referred to as the Scope of the variable.
    To identify the cause of your error, we need to know what the name of the variable is, and where the variable is declared.

    I would suggest doing a web search on "vb.net variable scope" and do some reading up on the topic. You may be able to solve the issue yourself and learn more in the process than having us identify a single instance of scoping issue that you may have in your existing code.
    "Anyone can do any amount of work, provided it isn't the work he is supposed to be doing at that moment" Robert Benchley, 1930

  4. #4
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    107,126

    Re: Compile error variable not found

    Quote Originally Posted by Somuchluv View Post
    My project when I want to compile it will tells me compile error variable not defined.
    The only reason that you would get an error message telling you that a variable is not defined is because a variable is not defined. The solution is to define it. Maybe it would help if you were to show us the code in which the error message is generated and the code in which you think you have defined the variable, given that we have no psychic powers to see what you did wrong if we can't see what you did. We can make guesses or assumptions but then we could guess or assume wrong. We should not have to guess or assume anything that you already know, because you can tell us.

  5. #5
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    107,126

    Re: Compile error variable not found

    Quote Originally Posted by passel View Post
    Well that at least sounds good in that you must have Option Explicit turned on so you have to declare all your variables
    Given that Option Explicit is On by default, I'm not sure that any congratulations are in order for that fact. It's Option Strict that is Off by default and should be turned On immediately.

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