在Form2 :
1. 写成
set BBB = ClsABCE 光源码编译就过不了.
2. 写成
Set BBB = Form1.AAA 源码编译就过了.
--------------------------------------------------------------------
直接试了你的源码发现你设计的功能好像跟我要的刚好相反.
不过也差不多,也因此找到解决方向了.
--------------------------------------------------------------------
Form1:--------------------------------------------------------------
Public WithEvents AAA As ClsABCD
Private Sub AAA_Back()
Form1.Hide
Form2.Show
End Sub
Private Sub AAA_BackStruct(ByVal iCount As Integer)
ProgressBar1.Value = iCount
End Sub
Private Sub Command1_Click()
With AAA
.nCount = 100
.Run
End With
End Sub
Private Sub Form_Load()
Set AAA = New ClsABCD
ProgressBar1.Value = 0
Form2.Show
Form2.Hide
End Sub
Form2:--------------------------------------------------------------
Private WithEvents BBB As ClsABCD
Private Sub BBB_BackStruct(ByVal iCount As Integer)
ProgressBar1.Value = iCount
End Sub
Private Sub Form_Load()
Set BBB = Form1.AAA
ProgressBar1.Value = 0
End Sub
ClsABCD:--------------------------------------------------------------
Private mvarnCount As Integer
Public Event BackStruct(ByVal iCount As Integer)
Public Event Back()
Public Property Let nCount(ByVal vData As Integer)
mvarnCount = vData
End Property
Public Sub Run()
Dim i As Integer, j As Integer
For i = 0 To mvarnCount
RaiseEvent BackStruct(i)
Next i
RaiseEvent Back
For j = 0 To mvarnCount
RaiseEvent BackStruct(j)
Next j
End Sub