Thread: VB Question
View Single Post
Old 03-10-2003, 04:52 PM   #9
Night Stalker
Lord Ao
 

Join Date: June 24, 2002
Location: Nevernever Land
Age: 51
Posts: 2,002
Question Mark

If you can avoid it, don't use an untyped object or variant. While flexible, you don't know the type until runtime.

Now for your ? ....

It seems there is an invalid object reference in your sub. Are you passing the proper object? Does your object have the proper scope? e.i Is it a module global or a local to the _Load event? If it's local to _Load, then it is out of scope in the sub. Also, use a typed object variable. If the object is a textbox, declare it as a textbox ... this will help you at design time.

MAKE SURE YOU HAVE THIS STATEMENT IN EACH CODE MODULE AS THE FIRST LINE
.

code:
OPTION EXPLICIT
[/QUOTE]This forces variables to be specifically declared. Otherwise, if not declared in a particular scope, VB will create a new variable as variant. Goto to Tools '--> Options
and make sure the "Require variable declaration" option is checked. This makes VB put the statement in.

Always declare variables like this

code:
dim var as type
[/QUOTE]If you leave out the type, it is declared as a variant.
__________________
[url]\"http://www.duryea.org/pinky/gurkin.wav\" target=\"_blank\">AYPWIP?</a> .... <img border=\"0\" alt=\"[1ponder]\" title=\"\" src=\"graemlins/1ponder.gif\" /> <br />\"I think so Brain, but isn\'t a cucumber that small called a gherkin?\"<br /><br />Shut UP! Pinky!
Night Stalker is offline