|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
some advicethis 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 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 ***
Show quote
Hide quote
"Terry Olsen" <tolse***@hotmail.com> schrieb The type Object does not have a method 'Export'. This doesn't compile.> 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 Armin 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 "Terry Olsen" <tolse***@hotmail.com> schrieb: True.> 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 The cast is not necessary because 'Object' is the super type of any type.> this may work. > > dim oCr as Object > If var=a > oCr = ctype(MyReportName,reportType1) -- M S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://classicvb.org/petition/> Herfried,
>> dim oCr as Object Have a look at the answer from Armin.>> If var=a >> oCr = ctype(MyReportName,reportType1) > > The cast is not necessary because 'Object' is the super type of any type. > 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 "Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> schrieb: Huh?! 'Object' is the super type of any type, but 'HtmlControl' is not the >>> 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). 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/> Herfried,
> Huh?! 'Object' is the super type of any type, but 'HtmlControl' is not Not the super type, that is object, however Webcontrol it is the base for > the super type of 'WebControl' or any of its derived types. > the htmlcontrol. See my message in that thread to Armin (I was suprissed as well). Cor "Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> schrieb: That's wrong. Both, 'WebControl' and 'HtmlControl' inherit from >> 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). '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/> Herfried,
> Whatever but both don't have the member 'item' and that is for me what Armin > That's wrong. Both, 'WebControl' and 'HtmlControl' inherit from > 'System.Web.UI.Control', but neither one is the base type of the other > one. > is correct in. Object does as well not have all items from its derived classes. Cor
Show quote
Hide quote
"rodchar" <rodc***@discussions.microsoft.com> schrieb dim oCr as CrystalDecisions.CrystalReports.Engine.ReportDocument> 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? If var=a oCr = reportType1 'pseudo-code: assign the report object here elseif oCr = reportType2 endi if oCr.Export Armin 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 >
Show quote
Hide quote
"rodchar" <rodc***@discussions.microsoft.com> schrieb: If 'ReportType1' and 'ReportType2' have a common base type which defines the > 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? '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/>
The old Structure/Class Argument
Migrating From ListBox to ListView: Only One Problem DATE HELLLPPPP RTF Command.Close vs Command.Dispose Referencing Datagrid Information Problem on MSHFlexGrid BindingSource for a class - need a light bulb moment Change the write path for My.Application.Log.WriteEntry? newbie question vb.net bits |
|||||||||||||||||||||||