Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old July 17th, 2005, 09:46 PM
Rich Strang
Guest
 
Posts: n/a
Default 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


  #2  
Old July 17th, 2005, 09:46 PM
mayayana
Guest
 
Posts: n/a
Default 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$(sName, 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]


  #3  
Old July 17th, 2005, 09:46 PM
Rich Strang
Guest
 
Posts: n/a
Default 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


  #4  
Old July 17th, 2005, 09:46 PM
mayayana
Guest
 
Posts: n/a
Default 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]


 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles