Re: My FIRST Class!! But it doesn't work as expected - please HELP!



Thanks for the responses, guys. The one that seems to make it work as
I originally planned is the change below...

Private _generator As New Random ---> Private Shared
_generator As New Random

However, this runs contrary to what I would expect! 180 degrees
wrong!!!!
I would have thought that the code in the constructor would create a
random number between 1 - 6 (which it does) but in addition it would be
a different value for every new object that is instantiated by the die
class as part of the Dim myObject as New Die command (but it doesn't).
Why do they have the same value? I thought if you wanted a value to be
common throughout instantiation of a class THEN you used the SHARED
command - not the other way round as happens here. Using shared makes
instantiations of the Die Class begin with, well, a different number
from each other.

I think this is more of my lack of understanding of how the Random
command works and not my appreciation of OO programming. Do you agree?

.



Relevant Pages

  • Re: My FIRST Class!! But it doesnt work as expected - please HELP!
    ... The Random object is shared and only instantiated once. ... real world because the roll of one die actually uses the next rnd ... >class as part of the Dim myObject as New Die command. ... >common throughout instantiation of a class THEN you used the SHARED ...
    (microsoft.public.dotnet.languages.vb)
  • How can I reset the error counter displayed by "netstat -i" [Virus checked HSH Nordbank]
    ... I want to monitor the errors on the interfaces of some SUN Solaris servers. ... But i could not find a way or command to reset this counters to zero. ... Zugriff oder unbefugte Weiterleitung, die Fertigung einer Kopie, die ... Vervffentlichung oder sonstige in diesem Zusammenhang stehende Handlung ist ...
    (SunManagers)
  • Re: Windows/Macro Language Info?
    ... ueber Re: Windows/Macro Language Info? ... Also there was a command line version with ... "Die Interessen der Nation lassen sich nicht anders formulieren als unter ...
    (comp.lang.cobol)
  • Re: [opensuse] Help Killling Process
    ... will not die nor will it display anything. ... YouTube uses to display all its video. ... command to identify a process id and another one to kill a process. ... Kill is the command that sends signals to processes. ...
    (SuSE)
  • Re: beginner trying to use Getopt::Long
    ... run the program with various values at the command line (actually they ... use strict; ... die " program requires startdate argument \n"; ...
    (comp.lang.perl.misc)