|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
not getting 'variable not defined' with Option ExplicitI have an app that has multiple forms and procedures. I added a
string variable to a new procedure (in a form module) without dim'ing it and I am not getting a variable not defined error. I am also able to compile to an exe without any error messages. That same variable name is defined in a BAS module with a DIM. I have OPTION EXPLICIT on my first line of the FORM module. I think I have seen this similar behavior before recently in a different variable. However, I noticed it but I shut down VB and reopened my app and when I hit F5 it gave me the 'variable not defined' error. This is not happening this time though. David "vbDavidC" <davidsusergro***@yahoo.com> wrote in message try right-clicking the variable in the form code and selecting "Definition"; news:0e047110-26b6-4c06-88df-88cdc2dca3e0@z14g2000yqa.googlegroups.com... >I have an app that has multiple forms and procedures. I added a > string variable to a new procedure (in a form module) without dim'ing > it and I am not getting a variable not defined error. I am also able > to compile to an exe without any error messages. That same variable > name is defined in a BAS module with a DIM. I have OPTION EXPLICIT on > my first line of the FORM module. perhaps it is defined somewhere. If that fails post the cod that references the undeclared variable.
Show quote
Hide quote
"vbDavidC" <davidsusergro***@yahoo.com> wrote in message The OPTION EXPLICIT Declarative only impacts parsing behavior in the modulenews:0e047110-26b6-4c06-88df-88cdc2dca3e0@z14g2000yqa.googlegroups.com... > I have an app that has multiple forms and procedures. I added a > string variable to a new procedure (in a form module) without dim'ing > it and I am not getting a variable not defined error. I am also able > to compile to an exe without any error messages. That same variable > name is defined in a BAS module with a DIM. I have OPTION EXPLICIT on > my first line of the FORM module. > > I think I have seen this similar behavior before recently in a > different variable. However, I noticed it but I shut down VB and > reopened my app and when I hit F5 it gave me the 'variable not > defined' error. This is not happening this time though. > > David where it appears. You can insure all new modules have the Option declared by selecting "Tools"->"Options" and click "Require Variable Declaration". This will not retroactively add it to existing modules, you will have to do that manually. Right-click on the offending variable and select "Definition". This will take you the declaration. -ralph Thanks for the help.
I did have a declaration that I did not see before that I found based on you input about Declaration. One reason I thought I was right was because of my previous problem I had mentioned. thanks,
How to test for array?
Stone Wall GW-Basic DLL in Visual BASIC 6 Anyone know of a good Help Authorizing Tool Getting pixels from EMF (StdPicture) GetObject with VB6 ActiveX exe Mayayana and others: Know The Notes now for 98SE using MM's new 'Never Replace' scheme Format function question..... Create Icon File From Resource |
|||||||||||||||||||||||