Dim Cnn_1 As New ADODB.Connection
Dim Cnn_2 As New ADODB.Connection
Cnn_1 = Cnn_2 ‘ -- 成功, 当然前提是 Cnn_1 尚未连接到某数据库
Dim Z_1 As New Class_自己
Dim Z_2 As New Class_自己
Z_1 = Z_2 ‘ -- 失败==================================请问: Class 模块要如何写
才能像ADODB.Connection 那样 Cnn_1 = Cnn_2
不知道能够 Cnn_1 = Cnn_2 是如何办到的
Dim Cnn_2 As New ADODB.Connection
Cnn_1 = Cnn_2 ‘ -- 成功, 当然前提是 Cnn_1 尚未连接到某数据库
Dim Z_1 As New Class_自己
Dim Z_2 As New Class_自己
Z_1 = Z_2 ‘ -- 失败==================================请问: Class 模块要如何写
才能像ADODB.Connection 那样 Cnn_1 = Cnn_2
不知道能够 Cnn_1 = Cnn_2 是如何办到的
Dim Cnn_1 As New ADODB.Connection
Dim Cnn_2 As New ADODB.Connection
Cnn_1 = Cnn_2 '--? 成功, 当然前提是 Cnn_1 尚未连接到某数据库
Dim Z_1 As New Class_自己
Dim Z_2 As New Class_自己
Z_1 = Z_2 ' --? 失败
set Z_1 = Z_2 ' --? 成功,
嗨 大大就是要用 Z_1 = Z_2 , Z_2 变 Z_1 不会跟着变不用是用 set Z_1 = Z_2 ---> 这个方法 Z_1 将只是一个 指向 Z_2 的指针 , Z_2 变 Z_1 也会跟着变
问此问题
是因为 想知道是否用 VB6 能够写出 Z_1 = Z_2
Cnn_1 = Cnn_2
'完整表示为
Cnn_1.ConnectionString = Cnn_2.ConnectionString
'不表示
Set Cnn_1 = Cnn_2你的 Class_自己 有默认属性没有?
(1) ==================== Class_自己 ================== 内容如下Private GGGPublic Property Get Q() As Variant
Q = GGG
End PropertyPublic Property Let Q(ByVal vNewValue As Variant)
GGG = vNewValue
End Property(2)Cnn_1=Cnn_2 '完整表示为 Cnn_1.ConnectionString=Cnn_2.ConnectionString这好像如同 TextBox 耶Text1 = Text2 ----> 实际上里面运作的是 Text1.Text = Text2.Text那请问 VB6 如何也能办到这样Z_1 = Z_2 ----> 实际上运作的是 Z_1.Q = Z_2.Q
百度一下 vb 类 默认属性
答案容易找到
Private Sub Command1_Click()
Dim a As New Class1, b As New Class1
a.Name = "123"
b = a
Print b.Name
End Sub
eg:
dim Cnn_1 as new Class1
dim Cnn_2 as Objectset Cnn_1 = Cnn_1都行的