jtrowbridge
06-16-2008, 11:57 AM
I decided to take a swing at using properties and I'm ver quickly finding myself running into trouble. I've worked out a little code that is designed (more like intended) to have subroutine 1 gather and store data and then have subroutine 2 read and display the data with a message box.
It seems to be writing the data well enough. The trouble is that when the msgbox1 sub is called the data in the public properties seems to get zeroed out. I'm sure I'm missing something simple, does anyone know?
Also, is there a way to set up a property like an array? In a perfect world I'd like to declare something like this:
Public Property Let PassVar1(ByVal vNewValue As Variant), PassVar2(ByVal iNewValue as Integer), etc...
Here's the code that I'm struggling with: :think:
---------------------------------------------------
Public CalcVar As Integer
Public PromptVar As Date
'''''''
Public Property Get CalcIDPassVar() As Integer
PassVar = CalcVar
End Property
'''''''
Public Property Let CalcIDPassVar(ByVal NewValue As Integer)
CalcVar = NewValue
End Property
'''''''
Public Property Get PromptPassVar() As Date
PassVar = PromptVar
End Property
'''''''
Public Property Let PromptPassVar(ByVal NewValue As Date)
PromptVar = NewValue
End Property
'''''''
Sub test()
CalcIDPassVar = 100
PromptPassVar = "05/30/2008"
Call msgbox1
End Sub
Sub msgbox1()
MsgBox (CalcIDPassVar)
MsgBox (PromptPassVar)
End Sub
---------------------------------------------
Thanks!
It seems to be writing the data well enough. The trouble is that when the msgbox1 sub is called the data in the public properties seems to get zeroed out. I'm sure I'm missing something simple, does anyone know?
Also, is there a way to set up a property like an array? In a perfect world I'd like to declare something like this:
Public Property Let PassVar1(ByVal vNewValue As Variant), PassVar2(ByVal iNewValue as Integer), etc...
Here's the code that I'm struggling with: :think:
---------------------------------------------------
Public CalcVar As Integer
Public PromptVar As Date
'''''''
Public Property Get CalcIDPassVar() As Integer
PassVar = CalcVar
End Property
'''''''
Public Property Let CalcIDPassVar(ByVal NewValue As Integer)
CalcVar = NewValue
End Property
'''''''
Public Property Get PromptPassVar() As Date
PassVar = PromptVar
End Property
'''''''
Public Property Let PromptPassVar(ByVal NewValue As Date)
PromptVar = NewValue
End Property
'''''''
Sub test()
CalcIDPassVar = 100
PromptPassVar = "05/30/2008"
Call msgbox1
End Sub
Sub msgbox1()
MsgBox (CalcIDPassVar)
MsgBox (PromptPassVar)
End Sub
---------------------------------------------
Thanks!