Re: hiding an interface (VB6)

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: alpine (alpine_don'tsendspam_at_mvps.org)
Date: 04/30/04

  • Next message: U-CDK_CHARLES\\Charles: "Re: Step-by-step dialog?"
    Date: Fri, 30 Apr 2004 14:55:00 -0600
    
    

    >I didn't notice a check in your Init() to see if it had already been
    >initialized. Was that intentional?

    What do you call this? ;-)

    > If Not bInitialized Then

    HTH,
    Bryan
    ____________________________________________________________
    New Vision Software "When the going gets weird,"
    Bryan Stafford "the weird turn pro."
    alpine_don'tsendspam@mvps.org Hunter S. Thompson -
    Microsoft MVP-Visual Basic Fear and Loathing in LasVegas

    On Fri, 30 Apr 2004 12:48:43 -0400, "Mark Meyers"
    <mmeyers[at]hydromilling.com> wrote:

    >Right - these are good ideas (both posts), and they look much like the ideas
    >I've come up with.
    >
    >I didn't notice a check in your Init() to see if it had already been
    >initialized. Was that intentional?
    >
    >I have also created a smaller object from the original, and am now passing
    >the smaller one to callers. The bigger object remains contained, with all
    >of it's entrypoints private.
    >
    >Something like this:
    >' class BigObject
    >
    >private x as integer, y as integer
    >
    >' properties coded to read/write the x and y
    >
    >public function CreateSmallObject() _
    >as SmallObject
    > dim sm as SmallObject
    > set sm = new SmallObject
    > sm.Init(x,y)
    > set CreateSmallObject = sm
    >end sub
    >
    >' class SmallObject
    >
    >private bInit as boolean ' true when init has been done
    >private x as integer, y as integer
    >
    >' properties coded to read the x and y (not write)
    >
    >public function Init(newx as integer, newy as integer)
    > if bInit then
    > msgbox "You goofed"
    > Init = False
    > exit function
    > end if
    > x = newx
    > y = newy
    > bInit = True
    >end function
    >
    >- Mark
    >
    >"alpine" <alpine_don'tsendspam@mvps.org> wrote in message
    >news:mjr490leuk82igqhanpcmi4ufiocekfp76@4ax.com...
    >>
    >> If you are content with being able to set the values contained within
    >> the object when you initialize it, you could do something like the
    >> following that would only allow the contained values to be set on the
    >> first call to it's Init function....
    >>
    >> ' class objcet....
    >> Option Explicit
    >>
    >> Private m_sMemberData1 As String
    >> Private m_nMemberData2 As Long
    >> Private m_bMemberData3 As Boolean
    >>
    >> Public Function Init(ByVal sData1 As String, ByVal nData2 As Long,
    >> ByVal bData3 As Boolean) As Boolean
    >>
    >> Static bInitialized As Boolean
    >>
    >> If Not bInitialized Then
    >> bInitialized = True
    >>
    >> m_sMemberData1 = sData1
    >> m_nMemberData2 = nData2
    >> m_bMemberData3 = nData3
    >> End If
    >>
    >> End Function
    >>
    >> Public Property Get Data1() As String
    >> Data1 = m_sMemberData1
    >> End Property
    >>
    >> Public Property Get Data2() As Long
    >> Data2 = m_nMemberData2
    >> End Property
    >>
    >> Public Property Get Data3() As Boolean
    >> Data3 = m_bMemberData3
    >> End Property
    >>
    >>
    >> Another option would be to have your object implement an interface
    >> with "read only" access to the data contained within. You could then
    >> pass a reference to the read only interface to those who should only
    >> have read only access.
    >>
    >> HTH,
    >> Bryan
    >


  • Next message: U-CDK_CHARLES\\Charles: "Re: Step-by-step dialog?"

    Relevant Pages

    • Re: Please help: Exception in thread "Thread-3" java.lang.NullPointerException
      ... Don't override 'boolean mouseDown' to handle mouse events. ... mouselistener (in the init) to the applet instead on implement it's ... It still generates a NullPointer, because starPoint is never ... Initialize it in the init: ...
      (comp.lang.java.help)
    • Re: Atyfb questions and issues
      ... Then if the BIOS do the init, ... If it ends with 0x95, the chip has not been initialized, ... > otherwise I initialize it. ... clocked for DLLCLK and that kind of clocks, ...
      (Linux-Kernel)
    • Ruby Syntax: initialize versus init
      ... I've grown to love just how clear and concise ... the language is. ... Even in the Pickaxe book it points out that the spelling of 'initialize' as ... 'Init' seems simpler, to the point, and harder to mispell. ...
      (comp.lang.ruby)
    • Re: How to initialize class data?
      ... I've got some class data which I want to initialize once. ... The canonical way would be an INIT block. ... Foo is never instanciated. ...
      (comp.lang.perl.misc)
    • Re: Class problem
      ... It seems like you have the code to initialize it in the Prop1 ... > Public Class MyShape ... > Public layer As Short ' Layer ... > Public Property Prop1As Double ...
      (microsoft.public.dotnet.languages.vb)