Class Module Array cause the problem.
I found that the error is from the COM object.
Code:
'Method under the Class module (MapServer.cls)
Public Function Send2Client(ByVal data As String)
Dim i As Integer
For i = 0 To Idx - 1
'Here is the problem, my code seem to loss the f() array
'All array() is nothing
If Not f(i) Is Nothing Then
If f(i).Winsock1.State <> sckClosed Then
f(i).Winsock1.SendData data
End If
End If
DELAY 800
Next
End Function
Public Function OpenPort(ByVal port As Integer) As Boolean
With frmServer.Winsock1
If .State <> sckClosed Then .Close
.LocalPort = port
.Listen
End With
OpenPort = True
Idx = 0
Idx2 = 0
Exit Function
OpenPort_Err:
OpenPort = False
End Function
'Declaration under the module file (Params.bas)
Global f() As frmSocket
Global c() As String
Global i() As Integer
Global Idx As Integer
Global Idx2 As Integer
'Code under the frmServer
Private Sub Winsock1_ConnectionRequest(ByVal requestID As Long)
'Resize the array
ReDim Preserve f(Idx)
'Create new frmSocket
Set f(Idx) = New frmSocket
'Store the Object index
f(Idx).Tag = Idx
'Accept the winsock connection
f(Idx).Winsock1.Accept requestID
'Load the form
Load f(Idx)
'Increase counter by 1
'Idx = Idx + 1
End Sub
Problem
How can I hold the Array f() object in the Class module. or ceate a global access array in Class module?
Why the Idx and Idx2 value always reset to 0 in the Send2Client method. Although I did increase the counter in the Winsock1_ConnectionRequest event of the frmServer. WHY?
But with the same code, it running fine under the Win2000 Server+IIS+MTS. WHY?
regards,
Chris.C