Forgive me if this seems simple. I'm an old VB6 programmer new to OOP.
I have a class thus:
Public Class GetRandom
My parent form invokes method GetMeMyRndNums, but obviously the scope of randomclass is Disposed each time, and thus I do not have my Random(pseed) available. How can I "keep" randomclass within the scope of my parent form? I have thought about moving the class within the Form, but is there a better method.
Thanks,
Gary
I have a class thus:
Public Class GetRandom
Public seed As Integer
Public BeenThereDoneThat As Boolean
Property pSeed() As Integer
Public Sub GetMeMyRndNums(ByRef x As Byte, ByRef y As Byte)
Public Sub New(ByVal ScreenSeed As Integer)
End ClassPublic BeenThereDoneThat As Boolean
Property pSeed() As Integer
Get
Set(ByVal xSeed As Integer)
End PropertyReturn seed
End GetSet(ByVal xSeed As Integer)
seed = xSeed
End SetPublic Sub GetMeMyRndNums(ByRef x As Byte, ByRef y As Byte)
Dim randomclass
If Not BeenThereDoneThat Then
x = randomclass.Next(1, 4)
y = randomclass.Next(1, 4)
End SubIf Not BeenThereDoneThat Then
randomclass = New Random(pSeed)
BeenThereDoneThat = True
End IfBeenThereDoneThat = True
x = randomclass.Next(1, 4)
y = randomclass.Next(1, 4)
Public Sub New(ByVal ScreenSeed As Integer)
pSeed = CInt(ScreenSeed)
BeenThereDoneThat = False
End SubBeenThereDoneThat = False
My parent form invokes method GetMeMyRndNums, but obviously the scope of randomclass is Disposed each time, and thus I do not have my Random(pseed) available. How can I "keep" randomclass within the scope of my parent form? I have thought about moving the class within the Form, but is there a better method.
Thanks,
Gary
Last edited: