• Welcome to Valhalla Legends Archive.
 

[VB] ReDim Preserve with a Class Module

Started by Barumonk, April 12, 2003, 10:11 PM

Previous topic - Next topic

Barumonk

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.

Yoni

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).

Barumonk

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.

TheMinistered

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!

Banana fanna fo fanna

+1 to Barumonk for same reasons stated above.

Zakath

+1 to St0rm because he needs all the help he can get.
Quote from: iago on February 02, 2005, 03:07 PM
Yes, you can't have everybody...contributing to the main source repository.  That would be stupid and create chaos.

Opensource projects...would be dumb.


Noodlez

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