Activex control

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

    Activex control

    Hi

    I'm just starting out in VB so please be patient.

    I am creating an activex control, in the class there is a single variable
    that is to be validated when set. Currently I am using the let/get property
    to set and retrieve this value. Should I perform the validation within the
    let property or within a function that then calls the let, I ask this as a
    let does not seem to be able to return a value.

    Thanks in advance.

    Rich


  • mayayana

    #2
    Re: Activex control

    You can validate the value sent in the Let procedure
    to make sure it's a valid setting. Is that what you mean?
    If you want to return a result you need to use a function.

    Private Name1 as string

    Public Property Let Name(sName as string)
    '-- you can validate whether this incoming value is a relevant string
    '-- but you need a function to return a result. In this case, you'll
    '-- assign incoming value to property only if first letter is "m".
    '-- If they send "tree" the property will not be set but they won't
    '-- know that unless you raise an error.

    if (len(sName) > 0) then
    If Ucase$(Left$(sN ame, 1)) = "M" then Name1 = sName
    end if
    End Property

    Public Property Get Name() as String
    Name = Name1
    End Property
    [color=blue]
    >
    > I'm just starting out in VB so please be patient.
    >
    > I am creating an activex control, in the class there is a single variable
    > that is to be validated when set. Currently I am using the let/get[/color]
    property[color=blue]
    > to set and retrieve this value. Should I perform the validation within[/color]
    the[color=blue]
    > let property or within a function that then calls the let, I ask this as a
    > let does not seem to be able to return a value.
    >
    > Thanks in advance.
    >
    > Rich
    >
    >[/color]


    Comment

    • Rich Strang

      #3
      Re: Activex control

      [color=blue]
      > You can validate the value sent in the Let procedure
      > to make sure it's a valid setting. Is that what you mean?
      > If you want to return a result you need to use a function.[/color]

      Ok thanks I think I need to use a function then.

      Rich


      Comment

      • mayayana

        #4
        Re: Activex control

        There's no problem with that. The only reason to use
        a Property is because it's clean and easy from the other
        side. They can just use:

        s = Ob.Name
        or
        Ob.Name = s

        But you could also use a Boolean function:

        Public Function Name(sName as String) as Boolean

        and they'd then call it with:

        Bool1 = Ob.Name(s)
        If Bool1 = True then '-- s was valid.
        [color=blue][color=green]
        > > You can validate the value sent in the Let procedure
        > > to make sure it's a valid setting. Is that what you mean?
        > > If you want to return a result you need to use a function.[/color]
        >
        > Ok thanks I think I need to use a function then.
        >
        > Rich
        >
        >[/color]


        Comment

        Working...