TungVan
asked on
Set keyword
Hi,
I have a CButton class.
I created an instance of it called Dim mButton as CButton
I have a Temporary button object called Dim mTemp as CButton
I also have a AddButton function that takes 2 arguments: 1 flag, and 1 Button object
--------------------------
AddButton False, mTemp
Public Sub AddButton(ByVal NewButtonFlag As Boolean, Optional ByVal lButton As Object)
Dim lButtonIndex As Integer
lButtonIndex = myMapForm!cmdButton.UBound
ReDim Preserve mButtonArray(lButtonIndex)
'Flag = true means that we create a new button and put it into the array
If NewButtonFlag = True Then
Dim myButton As CButton
Set myButton = New CButton
Set mButtonArray(lButtonIndex)
Set myButton = Nothing
'Flag = false means that we copied the button in the function parameter into the array
ElseIf NewButtonFlag = False Then
Set mButtonArray(lButtonIndex)
Else
'do nothing
End If
Load myMapForm!cmdButton(lButto
myMapForm!cmdButton(lButto
myMapForm!cmdButton(lButto
myMapForm!cmdButton(lButto
myMapForm!cmdButton(lButto
PaintButton (lButtonIndex)
End Sub
--------------------------
But Set keyword set the pointer of mButtonArray(lButtonIndex)
Everytime I modify mTemp properties, it also set the properties of mButtonArray(lButtonIndex)
But that's not I wish to have. I just want to copy properties of mTemp to mButtonArray(lButtonIndex)
Do you have a idea for that? Except copying manually...like this
--------------------------
Dim lButtonIndex As Integer
lButtonIndex = myMapForm!cmdButton.UBound
ReDim Preserve mButtonArray(lButtonIndex)
Dim myButton As CButton
'Flag = true means that we create a new button and put it into the array
If NewButtonFlag = True Then
Set myButton = New CButton
Set mButtonArray(lButtonIndex)
Set myButton = Nothing
'Flag = false means that we copied the button in the function parameter into the array
ElseIf NewButtonFlag = False Then
Set myButton = New CButton
myButton.ButtonType = lButton.ButtonType
myButton.CControl_ControlL
Set mButtonArray(lButtonIndex)
Set myButton = Nothing
--------------------------
This works ok...But i have to copy each attribute manually one at a time....It's a bit tedious....Is there a better way to do it?
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.