ASE Home Page Products Download Purchase Support About ASE
ChartDirector Support
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  Run-time error
Posted by Daniel on May-23-2014 00:19
Attachments:
Hello Peter,
I have create an application based on chartdirector library and each time I get a run-time
error 13 "Type mismatch" on the plotarea row. It is a bit strange because I have a first
application, similar with current, that works very well. Both apps are based on your demo
sample, with that tree view. To understand better I attached a print screen with my error.
Thank you in advance for any suggestion about this bug.
Plotarea.PNG

  Re: Run-time error
Posted by Peter Kwan on May-23-2014 04:40
Hi Daniel,

This is in fact very strange. The line looks completely normal.

The only explanation I can think of is that there is another class that is also called
"plotArea" in your project. This other plotArea class can be created by your own code, or
can be imported from other components you may be using. So the line "Dim plotArea As
plotArea" is declaring the variable plotArea to be of the other plotArea class, not the
ChartDirector plotArea class. In this case, the next line will have type mismatch error,
because it is trying to assign the ChartDirector plotArea object to a variable of a different
type.

To test if this is the cause of the problem, instead of using "Dim plotArea As plotArea",
please simply use "Dim plotArea" to see if it works.

If the above still not work, is it possible to create a simple test project (by simplifying your
code to as simple as possible, and move it into the "vbHelloWorld" project) to allow me to
try to reproduce the problem?

Regards
Peter Kwan

  Re: Run-time error
Posted by Daniel on May-23-2014 16:10
Attachments:
Hi Peter,
Yes, after I changed the plotArea variable name as you suggested the app worked properly.
Strange is the fact that I have a second similar application where those variables are
declared as plotArea and I don't have any conflict ...
Now, after your modification, the plotArea variable is declared as variant (as you know, in
VB6 if a variable is not declared explicitly it is considered as variant). Other interesting thing
is I have noted that in memory are created two similar classes of plotArea each time, as
you can see below. Do you have any explanation for this phenomenon ? Why in your demo
(or in my first app) we do not have this bug and in this case the PlotArea class is doubled
each time ? Thank you.
plotarea class.PNG

  Re: Run-time error
Posted by Peter Kwan on May-23-2014 18:36
Hi Daniel,

The drop down list you see is created by your VB IDE (integrated development
environment). The list is not from ChartDirector. The VB IDE simply lists out all classes it
know in the list. The VB IDE knows ChartDirector classes because you probably have add
reference to ChartDirector in your project (using Project/Reference from the IDE menu
bar). The VB IDE also knows other classes, as you may have reference other components
or controls in your project.

In the drop down lists, only some of the classes are from ChartDirector. For example, the
"Point" and "Points" are not from ChartDirector. You see two "PlotArea". It is likely one of
them is from ChartDirector, and the other is from the other components or controls that
your project has referenced. For example, the Microsoft Excel object also has a class
called "PlotArea". If you use Dim xxx As PlotArea, VB would not know you are referring to
the PlotArea from ChartDirector, or the PlotArea from the other component or control,
and this is the cause of the "Type Mismatch Error".

In brief, this is likely not a bug in ChartDirector. It is because your project may have
reference ChartDirector and another component or control that also has a class called
PlotArea. The sample project included in ChartDirector does not reference other
components that have a class called PlotArea, so there is no duplication.

You may try to tell VB which PlotArea you are referring to by including the component
name, like using "ChartDirector.PlotArea" to specify that you are referring to the PlotArea
from ChartDirector.

Hope this can help.

Regards
Peter Kwan

  Re: Run-time error
Posted by Daniel on May-23-2014 19:01
Hello Peter,

I know that you live in Hong Kong and maybe you had not time until now to see my reply.
Meanwhile I have discovered the cause of the ChartDirector library conflict...The source is
not in my code. My application works together with Excel library and, of course, I have a
specific reference to Excel objects. That excel library has a native class PlotArea which the
same name as yours for ChartDirector ...
Now, any common application that uses both Excel and ChartDirector will have 2 similar
classes of PlotArea :) This would not be annoying if the application could recognize which is
the CD class and which is not.

I told you previously that I have other similar application that works without any conflict
and I wondered how is possible. The answer and the root of the issue lies in the order
within the reference process. If the CD library reference is made first we will not have any
bug on the ChartDirector side, but we will have a run-time error in excel if we call the same
vba PlotArea class in our application ...

In summary, an application that uses both ChartDirector and Excel will recognize - in case
of 2 classes with the same name - that PlotArea class of the library that is referenced first.
To avoid the bug, either you have luck or you should know the trick. Maybe, renaming that
PlotArea class as, let's say, PlotAreaCd will solve the issue in a simple way.

Regards,
Daniel

  Re: Run-time error
Posted by Peter Kwan on May-23-2014 20:32
Hi Daniel,

Have you tried to use ChartDirector.PlotArea instead of PlotArea?

Regards
Peter Kwan

  Re: Run-time error
Posted by Daniel on May-23-2014 21:10
Hi Peter,
I am sorry, you sent your reply above while I was composing my response.
Yes, I have replaced all PlotArea class declarations as you suggested, adding the
application as main object of the class. Now the variables have the library specificity.
I don't think this was a ChartDirector bug, maybe in many other situations a conflict among
the same name of the classes could be happen.

PS. Thanks to your effort to develop this chart library and to provide at any time a quick
support, these days I convinced my company to buy a new license for ChartDirector run-
time distribution.