Results 1 to 8 of 8

Thread: [RESOLVED] Undeclared Variables (?!Grrrr)

  1. #1

    Thread Starter
    Member
    Join Date
    Apr 2006
    Location
    Annapolis, MD
    Posts
    61

    Resolved [RESOLVED] Undeclared Variables (?!Grrrr)

    I'm updating some spaghetti that consistently uses an undeclared
    variable that I guess (based on context) is supposed to be interpreted as a String. The code both compiles and executes successfully.
    How is this possible?
    Tara, Curmudgeon-at-Large, Engineer in Spare Time

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Undeclared Variables (?!Grrrr)

    It is probably being considered a Variant.

    Are you going through and predeclaring them as they should be?

  3. #3

    Thread Starter
    Member
    Join Date
    Apr 2006
    Location
    Annapolis, MD
    Posts
    61

    Re: Undeclared Variables (?!Grrrr)

    Quote Originally Posted by Hack
    It is probably being considered a Variant.

    Are you going through and predeclaring them as they should be?
    Not sure what a Variant is. And I am predeclaring as I add new code to this
    already existent disaster that got dropped in my lap.

    So what is a Variant? (I'm new to VB...this forum and the MSDN website
    are my only available references.)

    Thanks.
    Tara, Curmudgeon-at-Large, Engineer in Spare Time

  4. #4
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Undeclared Variables (?!Grrrr)


  5. #5

    Thread Starter
    Member
    Join Date
    Apr 2006
    Location
    Annapolis, MD
    Posts
    61

    Re: Undeclared Variables (?!Grrrr)

    So if I'm reading this properly, it is indeed possible to not declare
    a variable and then VB assumes it's a variant?

    P.S. - coming from someone who's done a lot of Ada, C++ and some Java
    isn't this kind of bad practice?
    Tara, Curmudgeon-at-Large, Engineer in Spare Time

  6. #6
    A SQL Server fool GaryMazzone's Avatar
    Join Date
    Aug 2005
    Location
    Dover,NH
    Posts
    7,493

    Re: Undeclared Variables (?!Grrrr)

    That would depend on how the IDE is set up. The norm would be to have the compiler (and the IDE) insist that all variables are declared before being used.
    Sometimes the Programmer
    Sometimes the DBA

    Mazz1

  7. #7
    PowerPoster CDRIVE's Avatar
    Join Date
    Jul 2007
    Posts
    2,620

    Re: Undeclared Variables (?!Grrrr)

    Quote Originally Posted by tlwtheq
    So if I'm reading this properly, it is indeed possible to not declare
    a variable and then VB assumes it's a variant?

    P.S. - coming from someone who's done a lot of Ada, C++ and some Java
    isn't this kind of bad practice?
    Yes.... For some reason MS developers thought it would be handy to have VB default to not declaring variables unless Option Explicit is declared. Go figure!
    <--- Did someone help you? Please rate their post. The little green squares make us feel really smart!
    If topic has been resolved, please pull down the Thread Tools & mark it Resolved.


    Is VB consuming your life, and is that a bad thing??

  8. #8

    Thread Starter
    Member
    Join Date
    Apr 2006
    Location
    Annapolis, MD
    Posts
    61

    Re: Undeclared Variables (?!Grrrr)

    Quote Originally Posted by CDRIVE
    Yes.... For some reason MS developers thought it would be handy to have VB default to not declaring variables unless Option Explicit is declared. Go figure!
    Ahhh, MS developers. That explains a lot.

    Thanks everyone.
    Tara, Curmudgeon-at-Large, Engineer in Spare Time

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