Home All Groups Group Topic Archive Search About
Author
13 Jan 2006 5:41 PM
rodchar
hey all,

this is a repost because the more i thought about it the more i think i
posted in wrong area, please forgive me if redundant post. anyway:

i have a single function i'm working on;

If var=a
dim oCr as reportType1
elseif
dim oCr as reportType2
endi if

oCr.Export

I'm getting the squiggly under oCr.Export saying not defined. What is a good
way to resolve this?

thanks,
rodchar

Author
13 Jan 2006 6:05 PM
Terry Olsen
You are defining oCr inside an If block, which isn't visible outside the
If block.

I don't know what the rest of your code looks like so I'm not sure, but
this may work.

dim oCr as Object
If var=a
oCr = ctype(MyReportName,reportType1)
elseif
oCr = ctype(MyReportName,reportType2)
endi if

oCr.Export


*** Sent via Developersdex http://www.developersdex.com ***
Author
13 Jan 2006 6:08 PM
Armin Zingler
Show quote Hide quote
"Terry Olsen" <tolse***@hotmail.com> schrieb
> You are defining oCr inside an If block, which isn't visible outside
> the If block.
>
> I don't know what the rest of your code looks like so I'm not sure,
> but this may work.
>
> dim oCr as Object
> If var=a
> oCr = ctype(MyReportName,reportType1)
> elseif
> oCr = ctype(MyReportName,reportType2)
> endi if
>
> oCr.Export


The type Object does not have a method 'Export'. This doesn't compile.


Armin
Author
13 Jan 2006 6:12 PM
Marina
Unless you have Option Strict Off, which unfortunately many do. Of course
there would be no point of doing the CType then.

Show quoteHide quote
"Armin Zingler" <az.nospam@freenet.de> wrote in message
news:%23gxBzxGGGHA.2300@TK2MSFTNGP15.phx.gbl...
> "Terry Olsen" <tolse***@hotmail.com> schrieb
>> You are defining oCr inside an If block, which isn't visible outside
>> the If block.
>>
>> I don't know what the rest of your code looks like so I'm not sure,
>> but this may work.
>>
>> dim oCr as Object
>> If var=a
>> oCr = ctype(MyReportName,reportType1)
>> elseif
>> oCr = ctype(MyReportName,reportType2)
>> endi if
>>
>> oCr.Export
>
>
> The type Object does not have a method 'Export'. This doesn't compile.
>
>
> Armin
Author
13 Jan 2006 7:43 PM
Herfried K. Wagner [MVP]
"Terry Olsen" <tolse***@hotmail.com> schrieb:
> You are defining oCr inside an If block, which isn't visible outside the
> If block.

True.

> I don't know what the rest of your code looks like so I'm not sure, but
> this may work.
>
> dim oCr as Object
> If var=a
> oCr = ctype(MyReportName,reportType1)

The cast is not necessary because 'Object' is the super type of any type.

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://classicvb.org/petition/>
Author
14 Jan 2006 6:59 AM
Cor Ligthert [MVP]
Herfried,
>> dim oCr as Object
>> If var=a
>> oCr = ctype(MyReportName,reportType1)
>
> The cast is not necessary because 'Object' is the super type of any type.
>
Have a look at the answer from Armin.

Is that is the fact than your answer from yesterday about the html.control
was completely wrong. (While it was not in my opinion).



Cor
Author
14 Jan 2006 11:50 AM
Herfried K. Wagner [MVP]
"Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> schrieb:
>>> dim oCr as Object
>>> If var=a
>>> oCr = ctype(MyReportName,reportType1)
>>
>> The cast is not necessary because 'Object' is the super type of any type.
>>
> Have a look at the answer from Armin.
>
> Is that is the fact than your answer from yesterday about the html.control
> was completely wrong. (While it was not in my opinion).

Huh?!  'Object' is the super type of any type, but 'HtmlControl' is not the
super type of 'WebControl' or any of its derived types.

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://classicvb.org/petition/>
Author
14 Jan 2006 7:00 PM
Cor Ligthert [MVP]
Herfried,

> Huh?!  'Object' is the super type of any type, but 'HtmlControl' is not
> the super type of 'WebControl' or any of its derived types.
>
Not the super type, that is object, however Webcontrol it is the base for
the htmlcontrol. See my message in that thread to Armin (I was suprissed as
well).

Cor
Author
14 Jan 2006 7:22 PM
Herfried K. Wagner [MVP]
"Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> schrieb:
>> Huh?!  'Object' is the super type of any type, but 'HtmlControl' is not
>> the super type of 'WebControl' or any of its derived types.
>>
> Not the super type, that is object, however Webcontrol it is the base for
> the htmlcontrol. See my message in that thread to Armin (I was suprissed
> as well).

That's wrong.  Both, 'WebControl' and 'HtmlControl' inherit from
'System.Web.UI.Control', but neither one is the base type of the other one.

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://classicvb.org/petition/>
Author
14 Jan 2006 8:31 PM
Cor Ligthert [MVP]
Herfried,

>
> That's wrong.  Both, 'WebControl' and 'HtmlControl' inherit from
> 'System.Web.UI.Control', but neither one is the base type of the other
> one.
>
Whatever but both don't have the member 'item' and that is for me what Armin
is correct in.

Object does as well not have all items from its derived classes.

Cor
Author
13 Jan 2006 6:06 PM
Armin Zingler
Show quote Hide quote
"rodchar" <rodc***@discussions.microsoft.com> schrieb
> hey all,
>
> this is a repost because the more i thought about it the more i
> think i posted in wrong area, please forgive me if redundant post.
> anyway:
>
> i have a single function i'm working on;
>
> If var=a
> dim oCr as reportType1
> elseif
> dim oCr as reportType2
> endi if
>
> oCr.Export
>
> I'm getting the squiggly under oCr.Export saying not defined. What
> is a good way to resolve this?


dim oCr as CrystalDecisions.CrystalReports.Engine.ReportDocument

If var=a
    oCr = reportType1    'pseudo-code: assign the report object here
elseif
    oCr = reportType2
endi if

oCr.Export


Armin
Author
13 Jan 2006 9:05 PM
rodchar
looks like this one worked, thanks everyone for the great feedback.

Show quoteHide quote
"Armin Zingler" wrote:

> "rodchar" <rodc***@discussions.microsoft.com> schrieb
> > hey all,
> >
> > this is a repost because the more i thought about it the more i
> > think i posted in wrong area, please forgive me if redundant post.
> > anyway:
> >
> > i have a single function i'm working on;
> >
> > If var=a
> > dim oCr as reportType1
> > elseif
> > dim oCr as reportType2
> > endi if
> >
> > oCr.Export
> >
> > I'm getting the squiggly under oCr.Export saying not defined. What
> > is a good way to resolve this?
>
>
> dim oCr as CrystalDecisions.CrystalReports.Engine.ReportDocument
>
> If var=a
>     oCr = reportType1    'pseudo-code: assign the report object here
> elseif
>     oCr = reportType2
> endi if
>
> oCr.Export
>
>
> Armin
>
Author
13 Jan 2006 7:46 PM
Herfried K. Wagner [MVP]
Show quote Hide quote
"rodchar" <rodc***@discussions.microsoft.com> schrieb:
> this is a repost because the more i thought about it the more i think i
> posted in wrong area, please forgive me if redundant post. anyway:
>
> i have a single function i'm working on;
>
> If var=a
> dim oCr as reportType1
> elseif
> dim oCr as reportType2
> endi if
>
> oCr.Export
>
> I'm getting the squiggly under oCr.Export saying not defined. What is a
> good
> way to resolve this?

If 'ReportType1' and 'ReportType2' have a common base type which defines the
'Export' method, you can use something like this:

\\\
Dim cr As Report
If var = a Then
    cr = New ReportType1()
Else
    cr = New ReportType2()
End If
cr.Export()
///

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://classicvb.org/petition/>