Option Strict On

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

    #1

    Option Strict On

    I have employed a "Singleton mode" of programming for this project.

    I have a class that exposes some properties of the class "Sample" to other
    forms....

    If I set Option Strict On, I get many "Option Strict On disallows late
    binding" errors (see below)

    How might I fix this ?


    Public Class Sample

    Private Shared DInstance As Sample = Nothing
    Private Sub New()

    ' This call is required by the Windows Form Designer.
    InitializeCompo nent()

    ' Add any initialization after the InitializeCompo nent() call.

    End Sub

    Public Shared ReadOnly Property Instance()
    Get
    If (DInstance Is Nothing) Then DInstance = New Sample()
    Return DInstance

    End Get
    End Property

    Public Property TabControlAvail able() As TabControl
    Get
    Return Me.TabControl1

    End Get
    Set(ByVal value As TabControl)
    Me.TabControl1 = value

    End Set
    End Property

    Public Property SelectedTabAvai lable() As TabPage
    Get
    Return Me.TabControl1. SelectedTab
    End Get
    Set(ByVal value As TabPage)
    Me.TabControl1. SelectedTab = value
    End Set
    End Property


    ' These are the rows where the errors are pointing to...
    Sample.Instance .Visible = True
    Sample.Instance .TopMost = True
    Sample.Instance .TabControlAvai lable.SelectTab (strTabPageName )
    Sample.Instance .Show()


  • rowe_newsgroups

    #2
    Re: Option Strict On

    On Jun 7, 11:17 am, "Rob" <r...@yahoo.com wrote:
    I have employed a "Singleton mode" of programming for this project.
    >
    I have a class that exposes some properties of the class "Sample" to other
    forms....
    >
    If I set Option Strict On, I get many "Option Strict On disallows late
    binding" errors (see below)
    >
    How might I fix this ?
    >
    Public Class Sample
    >
    Private Shared DInstance As Sample = Nothing
    Private Sub New()
    >
    ' This call is required by the Windows Form Designer.
    InitializeCompo nent()
    >
    ' Add any initialization after the InitializeCompo nent() call.
    >
    End Sub
    >
    Public Shared ReadOnly Property Instance()
    Get
    If (DInstance Is Nothing) Then DInstance = New Sample()
    Return DInstance
    >
    End Get
    End Property
    >
    Public Property TabControlAvail able() As TabControl
    Get
    Return Me.TabControl1
    >
    End Get
    Set(ByVal value As TabControl)
    Me.TabControl1 = value
    >
    End Set
    End Property
    >
    Public Property SelectedTabAvai lable() As TabPage
    Get
    Return Me.TabControl1. SelectedTab
    End Get
    Set(ByVal value As TabPage)
    Me.TabControl1. SelectedTab = value
    End Set
    End Property
    >
    ' These are the rows where the errors are pointing to...
    Sample.Instance .Visible = True
    Sample.Instance .TopMost = True
    Sample.Instance .TabControlAvai lable.SelectTab (strTabPageName )
    Sample.Instance .Show()
    Off hand the one major problem I see is that you don't have the
    Instance shared property declared as a type. Add "As Sample" and see
    if it clears up anything.

    Thanks,

    Seth Rowe

    Comment

    • Rob

      #3
      Re: Option Strict On

      Seth,

      You are too good... it cleared up all errors.

      Thanks,
      Rob


      "rowe_newsgroup s" <rowe_email@yah oo.comwrote in message
      news:1181231958 .438608.235880@ q75g2000hsh.goo glegroups.com.. .
      On Jun 7, 11:17 am, "Rob" <r...@yahoo.com wrote:
      >I have employed a "Singleton mode" of programming for this project.
      >>
      >I have a class that exposes some properties of the class "Sample" to
      >other
      >forms....
      >>
      >If I set Option Strict On, I get many "Option Strict On disallows late
      >binding" errors (see below)
      >>
      >How might I fix this ?
      >>
      >Public Class Sample
      >>
      > Private Shared DInstance As Sample = Nothing
      > Private Sub New()
      >>
      > ' This call is required by the Windows Form Designer.
      > InitializeCompo nent()
      >>
      > ' Add any initialization after the InitializeCompo nent() call.
      >>
      > End Sub
      >>
      > Public Shared ReadOnly Property Instance()
      > Get
      > If (DInstance Is Nothing) Then DInstance = New Sample()
      > Return DInstance
      >>
      > End Get
      > End Property
      >>
      > Public Property TabControlAvail able() As TabControl
      > Get
      > Return Me.TabControl1
      >>
      > End Get
      > Set(ByVal value As TabControl)
      > Me.TabControl1 = value
      >>
      > End Set
      > End Property
      >>
      > Public Property SelectedTabAvai lable() As TabPage
      > Get
      > Return Me.TabControl1. SelectedTab
      > End Get
      > Set(ByVal value As TabPage)
      > Me.TabControl1. SelectedTab = value
      > End Set
      > End Property
      >>
      >' These are the rows where the errors are pointing to...
      >Sample.Instanc e.Visible = True
      >Sample.Instanc e.TopMost = True
      >Sample.Instanc e.TabControlAva ilable.SelectTa b(strTabPageNam e)
      >Sample.Instanc e.Show()
      >
      Off hand the one major problem I see is that you don't have the
      Instance shared property declared as a type. Add "As Sample" and see
      if it clears up anything.
      >
      Thanks,
      >
      Seth Rowe
      >

      Comment

      • Phill W.

        #4
        Re: Option Strict On

        Rob wrote:
        I have a class that exposes some properties of the class "Sample" to other
        forms....
        >
        If I set Option Strict On, I get many "Option Strict On disallows late
        binding" errors (see below)
        /"If"/ you set it on???
        IMHO, you should have this set it on /by default/ (under Tools >
        Options) so that you always get told about this sort of thing.
        Public Shared ReadOnly Property Instance() ???
        I'd have expected the error to be something more like:

        "Option Strict On requires all function and property declarations to
        have an 'As' clause."

        which (a) you're missing and (b) is far more explanatory, as error
        messages go (in fairness, it's probably buried in amongst all the other
        errors).

        Add "As Sample" to your Property and you'll be fine.

        HTH,
        Phill W.

        Comment

        • rowe_newsgroups

          #5
          Re: Option Strict On

          On Jun 8, 7:41 am, "Phill W." <p-.-a-.-w-a-r...@-o-p-e-n-.-a-c-.-u-k>
          wrote:
          Rob wrote:
          I have a class that exposes some properties of the class "Sample" to other
          forms....
          >
          If I set Option Strict On, I get many "Option Strict On disallows late
          binding" errors (see below)
          >
          /"If"/ you set it on???
          IMHO, you should have this set it on /by default/ (under Tools >
          Options) so that you always get told about this sort of thing.
          >
          Public Shared ReadOnly Property Instance() ???
          >
          I'd have expected the error to be something more like:
          >
          "Option Strict On requires all function and property declarations to
          have an 'As' clause."
          >
          which (a) you're missing and (b) is far more explanatory, as error
          messages go (in fairness, it's probably buried in amongst all the other
          errors).
          >
          Add "As Sample" to your Property and you'll be fine.
          >
          HTH,
          Phill W.
          "Option Strict On requires all function and property declarations to
          have an 'As' clause."
          As the OP didn't mention version, I wonder if this is just the VS 2005
          message - perhaps 2003 warns of late binding on undeclared properties?

          Thanks,

          Seth Rowe

          Comment

          • Rob

            #6
            Re: Option Strict On

            Regarding,
            >>Option Strict On requires all function and property declarations to
            >>have an 'As' clause
            Yes, there was one of those, but when the "As type" was added it was
            removed with the rest of the "late binding errors"

            Thanks,
            Rob


            "rowe_newsgroup s" <rowe_email@yah oo.comwrote in message
            news:1181304782 .181383.69060@w 5g2000hsg.googl egroups.com...
            On Jun 8, 7:41 am, "Phill W." <p-.-a-.-w-a-r...@-o-p-e-n-.-a-c-.-u-k>
            wrote:
            >Rob wrote:
            I have a class that exposes some properties of the class "Sample" to
            other
            forms....
            >>
            If I set Option Strict On, I get many "Option Strict On disallows late
            binding" errors (see below)
            >>
            >/"If"/ you set it on???
            >IMHO, you should have this set it on /by default/ (under Tools >
            >Options) so that you always get told about this sort of thing.
            >>
            > Public Shared ReadOnly Property Instance() ???
            >>
            >I'd have expected the error to be something more like:
            >>
            >"Option Strict On requires all function and property declarations to
            >have an 'As' clause."
            >>
            >which (a) you're missing and (b) is far more explanatory, as error
            >messages go (in fairness, it's probably buried in amongst all the other
            >errors).
            >>
            >Add "As Sample" to your Property and you'll be fine.
            >>
            >HTH,
            > Phill W.
            >
            >
            >"Option Strict On requires all function and property declarations to
            >have an 'As' clause."
            >
            As the OP didn't mention version, I wonder if this is just the VS 2005
            message - perhaps 2003 warns of late binding on undeclared properties?
            >
            Thanks,
            >
            Seth Rowe
            >

            Comment

            • rowe_newsgroups

              #7
              Re: Option Strict On

              On Jun 8, 12:44 pm, "Rob" <r...@yahoo.com wrote:
              Regarding,
              >
              >Option Strict On requires all function and property declarations to
              >
              >>have an 'As' clause
              >
              Yes, there was one of those, but when the "As type" was added it was
              removed with the rest of the "late binding errors"
              >
              Thanks,
              Rob
              >
              "rowe_newsgroup s" <rowe_em...@yah oo.comwrote in message
              >
              news:1181304782 .181383.69060@w 5g2000hsg.googl egroups.com...
              >
              >
              >
              On Jun 8, 7:41 am, "Phill W." <p-.-a-.-w-a-r...@-o-p-e-n-.-a-c-.-u-k>
              wrote:
              Rob wrote:
              I have a class that exposes some properties of the class "Sample" to
              other
              forms....
              >
              If I set Option Strict On, I get many "Option Strict On disallows late
              binding" errors (see below)
              >
              /"If"/ you set it on???
              IMHO, you should have this set it on /by default/ (under Tools >
              Options) so that you always get told about this sort of thing.
              >
              Public Shared ReadOnly Property Instance() ???
              >
              I'd have expected the error to be something more like:
              >
              "Option Strict On requires all function and property declarations to
              have an 'As' clause."
              >
              which (a) you're missing and (b) is far more explanatory, as error
              messages go (in fairness, it's probably buried in amongst all the other
              errors).
              >
              Add "As Sample" to your Property and you'll be fine.
              >
              HTH,
              Phill W.
              >
              "Option Strict On requires all function and property declarations to
              have an 'As' clause."
              >
              As the OP didn't mention version, I wonder if this is just the VS 2005
              message - perhaps 2003 warns of late binding on undeclared properties?
              >
              Thanks,
              >
              Seth Rowe- Hide quoted text -
              >
              - Show quoted text -
              I believe what Phill means is that errors are often cascading. The
              root error was the "as type" problem, which caused the others. When
              debugging it's important to not just focus on a certain error, but on
              all the errors. If you would have posted all the error messages we
              would have been able to solve the problem faster.

              Thanks,

              Seth Rowe

              Comment

              Working...