Home All Groups Group Topic Archive Search About

Why am I getting Method or data member not found?

Author
19 Mar 2009 12:59 PM
MM
Here's the code that works:

Load IC74xx259(IC74xx259.Ubound + 1)
With IC74xx259(IC74xx259.Ubound)
            .Visible = True
            .CurrentX = 35
            .CurrentY = 15
            IC74xx259(.Index).Print "IC" & .Index
End With


Here's the code that generates a Compile Error, Method or data member
not found:

Load IC74xx259(IC74xx259.Ubound + 1)
With IC74xx259(IC74xx259.Ubound)
            .Visible = True
            .CurrentX = 35
            .CurrentY = 15
            .Print "IC" & .Index
End With

Why does it barf over the .Print if the abbreviated dot notation is
used?

MM

Author
19 Mar 2009 1:20 PM
Jeff Johnson
"MM" <kylix***@yahoo.co.uk> wrote in message
news:inf4s4lcp2ispdf34hicj7rl7og51ibpkd@4ax.com...

> Why does it barf over the .Print if the abbreviated dot notation is
> used?

Because it's VB. You simply MUST use Printer.Print. Nothing but a quirk.
Author
19 Mar 2009 1:45 PM
Michael Williams
"MM" <kylix***@yahoo.co.uk> wrote in message
news:inf4s4lcp2ispdf34hicj7rl7og51ibpkd@4ax.com...

> Here's the code that generates a Compile Error,
> Method or data member not found:
> Load IC74xx259(IC74xx259.Ubound + 1)
> With IC74xx259(IC74xx259.Ubound)
>            .Visible = True
>            .CurrentX = 35
>            .CurrentY = 15
>            .Print "IC" & .Index
> End With
> Why does it barf over the .Print

I'm afraid that's just the way it is. There are various things that cannot
be used in the normal way in a With End With construct. Print is one of
them, regardless of the object on which you are using it. Most methods also
fail under such circumstances, such as Circle and Line and PSet and others.
For such things you need to fully qualify the object. I seem to remember
once reading a help file which suggested that methods (as opposed to
properties) could not be used in that manner, although in the current help
files it does not say that, at least in the files I've got. You can of
course use something other than a With End With construct, perhaps a
Function instead and pass the object to it, but if you want to use With End
With then I'm afraid you've just got to live with its limitations.

Mike
Author
19 Mar 2009 2:49 PM
Bob Butler
Show quote Hide quote
"MM" <kylix***@yahoo.co.uk> wrote in message
news:inf4s4lcp2ispdf34hicj7rl7og51ibpkd@4ax.com...
> Here's the code that works:
>
> Load IC74xx259(IC74xx259.Ubound + 1)
> With IC74xx259(IC74xx259.Ubound)
>            .Visible = True
>            .CurrentX = 35
>            .CurrentY = 15
>            IC74xx259(.Index).Print "IC" & .Index
> End With
>
>
> Here's the code that generates a Compile Error, Method or data member
> not found:
>
> Load IC74xx259(IC74xx259.Ubound + 1)
> With IC74xx259(IC74xx259.Ubound)
>            .Visible = True
>            .CurrentX = 35
>            .CurrentY = 15
>            .Print "IC" & .Index
> End With
>
> Why does it barf over the .Print if the abbreviated dot notation is
> used?

Look in the object viewer or the intellisense list that pops up when you
type the '.' -- Print is not a method of the object that the With variable
references.  The VB compiler is handling Print as a special case and it's a
limitation (or a bug depending on how you look at it) that it can't figure
it out inside the With block.

This special handling came in with VB4 and back then MS was still concerned
enough about people being able to move code forward that they went the extra
mile to implement the drawing methods in such a way that it would have
minimal effect on existing code.  Now, of course, anything that doesn't fit
cleanly in the latest paradigm is considered anathema and anybody using it
is ridiculed.

Not that I harbor any anger or anything... <g>