property let and get, 
Author Message
 property let and get,

Hi!
Is it possible to build a complex constructor in VB ? I explain :

Imagine a person with a name and a surname
    usually we do
            property let Name (Aname as string)
                    strTheName = Aname
            end property

            property get Name () as String
                    Name = strTheName
            end property

            and exactly the same thing for the surname
I would like to know if it's possible to have

            property Let NameSurname (Aname as string, Asurname as string)
                    strTheName = Aname
                    strTheSurname= Asurname
     end property

            property Get NameSurname () as String

                    and here big problem cos' my get property should give me
access to two properties.....

Does anyone have ideas?Is it possible or am I simply finding out a big
inconvenient of VB!!!!

THANKS FOR YOUR HELP...



Sat, 27 Dec 2003 05:52:40 GMT  
 property let and get,
Hi,

For more details, see the French ng.

We can only return ONE thing as a result. It can be an array.

The arguments of a LET have to be of the same type than the arguments of the
GET, except the last one in the LET, sure, which most correspond to the data
type of the result of the LET.

With VB6/VBA6, it is easy to assign un-restricted array (I forgot the
official name, the kind of array you get with the following:

Dim X ( ) As String

), so, it is relatively easy to get the goal you want.

Tourlou,
Vanderghast, Access MVP


Quote:
> Hi!
> Is it possible to build a complex constructor in VB ? I explain :

> Imagine a person with a name and a surname
>     usually we do
>             property let Name (Aname as string)
>                     strTheName = Aname
>             end property

>             property get Name () as String
>                     Name = strTheName
>             end property

>             and exactly the same thing for the surname
> I would like to know if it's possible to have

>             property Let NameSurname (Aname as string, Asurname as string)
>                     strTheName = Aname
>                     strTheSurname= Asurname
>      end property

>             property Get NameSurname () as String

>                     and here big problem cos' my get property should give
me
> access to two properties.....

> Does anyone have ideas?Is it possible or am I simply finding out a big
> inconvenient of VB!!!!

> THANKS FOR YOUR HELP...



Sat, 27 Dec 2003 06:27:41 GMT  
 property let and get,
As Michel Walsh suggests elsewhere in this thread, you could use an array.
(The term Michel was looking for was 'dynamic', as in 'dynamic array'. See
the help topic 'Declaring Arrays'.) From the example you gave, though, I'm
wondering why you would need to do this? Why do you need one property to
return the two values, when you can easily achieve the same result by a)
concatenating the values of two properties (strFullName = obj.FirstName & "
" & obj.LastName or b) providing a method of the class to concatenate them:

Public Function FullName () As String
    FullName = mstrFirstName & " " & mstrLastName
End Function

--
Brendan Reynolds

http://www11.ewebcity.com/brenreyn


Quote:
> Hi!
> Is it possible to build a complex constructor in VB ? I explain :

> Imagine a person with a name and a surname
>     usually we do
>             property let Name (Aname as string)
>                     strTheName = Aname
>             end property

>             property get Name () as String
>                     Name = strTheName
>             end property

>             and exactly the same thing for the surname
> I would like to know if it's possible to have

>             property Let NameSurname (Aname as string, Asurname as string)
>                     strTheName = Aname
>                     strTheSurname= Asurname
>      end property

>             property Get NameSurname () as String

>                     and here big problem cos' my get property should give
me
> access to two properties.....

> Does anyone have ideas?Is it possible or am I simply finding out a big
> inconvenient of VB!!!!

> THANKS FOR YOUR HELP...



Sat, 27 Dec 2003 06:42:03 GMT  
 property let and get,
The arguments have to be exactly the same, but you can declare them as optional.  If they are optional they don't have to be there.

(david)

Quote:

> Hi!
> Is it possible to build a complex constructor in VB ? I explain :

> Imagine a person with a name and a surname
>     usually we do
>             property let Name (Aname as string)
>                     strTheName = Aname
>             end property

>             property get Name () as String
>                     Name = strTheName
>             end property

>             and exactly the same thing for the surname
> I would like to know if it's possible to have

>             property Let NameSurname (Aname as string, Asurname as string)
>                     strTheName = Aname
>                     strTheSurname= Asurname
>      end property

>             property Get NameSurname () as String

>                     and here big problem cos' my get property should give me
> access to two properties.....

> Does anyone have ideas?Is it possible or am I simply finding out a big
> inconvenient of VB!!!!

> THANKS FOR YOUR HELP...



Sat, 27 Dec 2003 15:16:36 GMT  
 property let and get,
I think the problem here is that unlike properties should not be "matched"
as if they are alike. The LET prop that asks for the entries to be separate
can be matched by a different "FullName" SET prop that returns the full
name.

Its not an inconvenience of VB so much as an attempt to do the wrong thing
on Sylvain's part.

--
MichKa

the only book on internationalization in VB at
http://www.i18nWithVB.com/



Quote:
> The arguments have to be exactly the same, but you can declare them as

optional.  If they are optional they don't have to be there.
Quote:

> (david)




Quote:
> > Hi!
> > Is it possible to build a complex constructor in VB ? I explain :

> > Imagine a person with a name and a surname
> >     usually we do
> >             property let Name (Aname as string)
> >                     strTheName = Aname
> >             end property

> >             property get Name () as String
> >                     Name = strTheName
> >             end property

> >             and exactly the same thing for the surname
> > I would like to know if it's possible to have

> >             property Let NameSurname (Aname as string, Asurname as
string)
> >                     strTheName = Aname
> >                     strTheSurname= Asurname
> >      end property

> >             property Get NameSurname () as String

> >                     and here big problem cos' my get property should
give me
> > access to two properties.....

> > Does anyone have ideas?Is it possible or am I simply finding out a big
> > inconvenient of VB!!!!

> > THANKS FOR YOUR HELP...



Sat, 27 Dec 2003 20:07:04 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. property get / property let

2. Property Let, Property Get

3. Property Let vs. Property Set

4. Property Get, Set Let with Classes

5. Error 451: let property not defined

6. Property Let Procedure Error

7. Property Let problem

8. Using arrays as arguments in Let and Get Properties

9. Class Property Get Let

10. Property Let/Get and passing arrays

11. Syntax - Property Let for class object

12. Property Let=Null???

 

 
Powered by phpBB® Forum Software