vb6里面如何实现类似VB.net的clone实例?

超级大笨狼 2007-01-04 01:40:24
'local variable(s) to hold property value(s)
Private mvarA As String 'local copy


Public Property Let A(ByVal vData As String)
'used when assigning a value to the property, on the left side of an assignment.
'Syntax: X.A = 5
mvarA = vData
End Property


Public Property Get A() As String
'used when retrieving value of a property, on the right side of an assignment.
'Syntax: Debug.Print X.A
A = mvarA
End Property
------------------------------------------------------------
'local variable(s) to hold property value(s)
Private mvarA As String 'local copy


Public Property Let A(ByVal vData As String)
'used when assigning a value to the property, on the left side of an assignment.
'Syntax: X.A = 5
mvarA = vData
End Property


Public Property Get A() As String
'used when retrieving value of a property, on the right side of an assignment.
'Syntax: Debug.Print X.A
A = mvarA
End Property



byval不起作用,vb6里面如何实现VB.net的clone实例?
...全文
236 4 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
viena 2007-01-04
  • 打赏
  • 举报
回复
逐个赋值~
supergreenbean 2007-01-04
  • 打赏
  • 举报
回复
只能自己写深度拷贝的代码,即,一个一个属性写过去
超级大笨狼 2007-01-04
  • 打赏
  • 举报
回复
Private Sub Form_Load()
Dim testA, testB, testC
Set testA = New Class1
''MsgBox testA.Property(0)
''MsgBox CStr(testA.Class)
testA.A = "A"

Set testB = testA
testB.A = "B"
MsgBox testA.A

Set testC = clone(testA)
testC.A = "C"
MsgBox testA.A
'' testA.a=
End Sub

Private Function clone(ByVal instance) As Class1
Set clone = New Class1
Set clone = instance
End Function
超级大笨狼 2007-01-04
  • 打赏
  • 举报
回复
很久没做过VB了,回头看觉得很不爽.

7,785

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧