Re: How to create array class?



Hi all,

thanks for the help.
Finally, _AnonCoward has identified the root cause which i almost forget
:shared syntax.

Thanks for all the help given.

Rgrds,
GL

"_AnonCoward" wrote:


"Daniel" <Daniel@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:DB4E9F2F-9C1A-49E6-9088-E5F900F7FB83@xxxxxxxxxxxxxxxx
: Hi all,
:
: thanks for your response.
: I managed to solve the "object reference to null..." error
: message,however, another issue appears.
:
: I cannot get the list of 5 different records to be updated into the
: class arrays, for instance:
:
: inputs:
: eply(0).name="Krish"
: eply(1).name="James"
: eply(2).name="Bond"
:
: outputs:
: all display as "Bond" name which is the last record during updating.
:
: In my class, my code as follow:
: public shared sname as string
:
: Public Shared Property name() As String
: Get
: Return sname
: End Get
: Set(ByVal Value As String)
: sname = Value
: End Set
: End Property
:
: Any advice, please.
:
: thank you in advance.


Sorry for the earlier response. I fat fingered and inadvetantly sent
the post. Oops...


Anyway, your name variable (sName) is Shared which means there is only
one copy of it. When each object's name property is being set, they
are all setting the value of the same variable. Try removing the
Shared keyword.


Ralf
--
--
----------------------------------------------------------
* ^~^ ^~^ *
* _ {~ ~} {~ ~} _ *
* /_``>*< >*<''_\ *
* (\--_)++) (++(_--/) *
----------------------------------------------------------
There are no advanced students in Aikido - there are only
competent beginners. There are no advanced techniques -
only the correct application of basic principles.




.



Relevant Pages

  • Re: How to create array class?
    ... : class arrays, for instance: ... public shared sname as string ... Public Shared Property nameAs String ... There are no advanced students in Aikido - there are only ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Help with class
    ... : Public fName As String ... CollectionBase derived class, you'll probably want some functions to ... load the existing data and save the new data from and to your .dat file. ... There are no advanced students in Aikido - there are only ...
    (microsoft.public.dotnet.languages.vb)
  • VB .NET 1.1: passing a class array byref does not work as intended
    ... I found a problem when using the NEW contructor with class arrays ... Public DrillLevel_Desc As String ... Private Sub Add_To_rSummary ... ReDim Preserve vSummary ...
    (microsoft.public.vb.general.discussion)
  • Re: Help creating a function
    ... Dim sStr as string ... Public Sub Entry ... There are no advanced students in Aikido - there are only ...
    (microsoft.public.dotnet.languages.vb)
  • Re: when to use stringBuilder vs string concatenation?
    ... : Private Sub buildQueryString() ... Would a string builder be something I could use here or is ... compared the peformance of string concatenation versus the ... There are no advanced students in Aikido - there are only ...
    (microsoft.public.dotnet.languages.vb)

Loading