Would it be possible to do this?
Public CModule() As New ClassModule
ReDim CModule(0)
...then later in the program...
ReDim Preserve CModule(UBound(CModule) + 1)
I was going to create a winsock using api in a class module and use this as a way to add a new socket without knowing how many would be needed beforehand, but I thought it would be best to ask first incase I might be wasting my time.
You can't do that.
If you want your Winsock class module to use events, it has to be declared WithEvents. And then, it can't be an array, or at least not a dynamically sized one (don't remember which).
Even if it was a class module that didn't use WithEvents, I'm pretty sure it's impossible to ReDim an array of class modules.
+1 (good coding style, well asked question).
Thanks, you just saved me alot of time and trouble. I'll find another way eventually, there is always a way to do something, it just depends on how hard you reach for it if you succeed or fail.
Perhaps we can help you explore for other alternatives. If you could post what you are trying to make, and what you want it to do etc... perhaps we can help!
+1 to Barumonk for same reasons stated above.
+1 to St0rm because he needs all the help he can get.
Damn.
If using a winsock API class, what you can do is add another paramter to all the events (Optional Index as Long) Then, when raising the event give the corresponding index.
And, in the procedure for it...
Private Sub CSocket_DataArrival(bytesTotal as long, Index as long)
Dim strData as string
CSocket(Index).GetData strdata
End Sub