some advice

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • rodchar

    #1

    some advice

    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
  • Terry Olsen

    #2
    Re: some advice

    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(MyReportN ame,reportType1 )
    elseif
    oCr = ctype(MyReportN ame,reportType2 )
    endi if

    oCr.Export


    *** Sent via Developersdex http://www.developersdex.com ***

    Comment

    • Armin Zingler

      #3
      Re: some advice

      "Terry Olsen" <tolsen64@hotma il.com> schrieb[color=blue]
      > 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(MyReportN ame,reportType1 )
      > elseif
      > oCr = ctype(MyReportN ame,reportType2 )
      > endi if
      >
      > oCr.Export[/color]


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


      Armin

      Comment

      • Armin Zingler

        #4
        Re: some advice

        "rodchar" <rodchar@discus sions.microsoft .com> schrieb[color=blue]
        > 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?[/color]


        dim oCr as CrystalDecision s.CrystalReport s.Engine.Report Document

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

        oCr.Export


        Armin

        Comment

        • Marina

          #5
          Re: some advice

          Unless you have Option Strict Off, which unfortunately many do. Of course
          there would be no point of doing the CType then.

          "Armin Zingler" <az.nospam@free net.de> wrote in message
          news:%23gxBzxGG GHA.2300@TK2MSF TNGP15.phx.gbl. ..[color=blue]
          > "Terry Olsen" <tolsen64@hotma il.com> schrieb[color=green]
          >> 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(MyReportN ame,reportType1 )
          >> elseif
          >> oCr = ctype(MyReportN ame,reportType2 )
          >> endi if
          >>
          >> oCr.Export[/color]
          >
          >
          > The type Object does not have a method 'Export'. This doesn't compile.
          >
          >
          > Armin[/color]


          Comment

          • Herfried K. Wagner [MVP]

            #6
            Re: some advice

            "Terry Olsen" <tolsen64@hotma il.com> schrieb:[color=blue]
            > You are defining oCr inside an If block, which isn't visible outside the
            > If block.[/color]

            True.
            [color=blue]
            > 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(MyReportN ame,reportType1 )[/color]

            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/>

            Comment

            • Herfried K. Wagner [MVP]

              #7
              Re: some advice

              "rodchar" <rodchar@discus sions.microsoft .com> schrieb:[color=blue]
              > 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?[/color]

              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/>

              Comment

              • rodchar

                #8
                Re: some advice

                looks like this one worked, thanks everyone for the great feedback.

                "Armin Zingler" wrote:
                [color=blue]
                > "rodchar" <rodchar@discus sions.microsoft .com> schrieb[color=green]
                > > 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?[/color]
                >
                >
                > dim oCr as CrystalDecision s.CrystalReport s.Engine.Report Document
                >
                > If var=a
                > oCr = reportType1 'pseudo-code: assign the report object here
                > elseif
                > oCr = reportType2
                > endi if
                >
                > oCr.Export
                >
                >
                > Armin
                >[/color]

                Comment

                • Cor Ligthert [MVP]

                  #9
                  Re: some advice

                  Herfried,[color=blue][color=green]
                  >> dim oCr as Object
                  >> If var=a
                  >> oCr = ctype(MyReportN ame,reportType1 )[/color]
                  >
                  > The cast is not necessary because 'Object' is the super type of any type.
                  >[/color]
                  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


                  Comment

                  • Herfried K. Wagner [MVP]

                    #10
                    Re: some advice

                    "Cor Ligthert [MVP]" <notmyfirstname @planet.nl> schrieb:[color=blue][color=green][color=darkred]
                    >>> dim oCr as Object
                    >>> If var=a
                    >>> oCr = ctype(MyReportN ame,reportType1 )[/color]
                    >>
                    >> The cast is not necessary because 'Object' is the super type of any type.
                    >>[/color]
                    > 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).[/color]

                    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/>

                    Comment

                    • Cor Ligthert [MVP]

                      #11
                      Re: some advice

                      Herfried,
                      [color=blue]
                      > Huh?! 'Object' is the super type of any type, but 'HtmlControl' is not
                      > the super type of 'WebControl' or any of its derived types.
                      >[/color]
                      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


                      Comment

                      • Herfried K. Wagner [MVP]

                        #12
                        Re: some advice

                        "Cor Ligthert [MVP]" <notmyfirstname @planet.nl> schrieb:[color=blue][color=green]
                        >> Huh?! 'Object' is the super type of any type, but 'HtmlControl' is not
                        >> the super type of 'WebControl' or any of its derived types.
                        >>[/color]
                        > 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).[/color]

                        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/>

                        Comment

                        • Cor Ligthert [MVP]

                          #13
                          Re: some advice

                          Herfried,
                          [color=blue]
                          >
                          > That's wrong. Both, 'WebControl' and 'HtmlControl' inherit from
                          > 'System.Web.UI. Control', but neither one is the base type of the other
                          > one.
                          >[/color]
                          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


                          Comment

                          Working...