Mar 10th, 2011, 06:24 AM
#1
Thread Starter
New Member
using array of class module in form load
I am going to make a program that use multiple winsock, and using a class module to create that winsock support socks proxy. Now i confused how to make array of that class in form to load multiple winsock. Thanks...........
Mar 10th, 2011, 08:12 AM
#2
Re: using array of class module in form load
You can use a collection.
VB6 Library
If I helped you then please help me and rate my post!
If you solved your problem, then please mark the post resolved
Mar 10th, 2011, 11:00 AM
#3
Thread Starter
New Member
Re: using array of class module in form load
I mean we load multiple winsock like this example:
set index to 0 of winsock property Window
then in command we just write "load winsock" and connect or close or sendata Like this "Winsock(index).senddata......"
So can I do the same in class module like set Myclass(index) = new Myclass or what
I need help on this...........
Mar 10th, 2011, 11:05 AM
#4
Re: using array of class module in form load
Please post a COMPLETE example of what you are doing otherwise it is unclear as to what to suggest.
VB6 Library
If I helped you then please help me and rate my post!
If you solved your problem, then please mark the post resolved
Mar 10th, 2011, 12:21 PM
#5
Thread Starter
New Member
Re: using array of class module in form load
This is the class module i have using, How to use this socket.cls multiple like Loading Multiple winsock.
suppose if i use winsock array(indexed winsock) to connect a site then method is
Code:
winsock(index).connect remote host, remote port
How to do the same with This class, how to declare that class as array
this code will make a single socket
Code:
Private WithEvents Socket1 As Socket
Code:
form load
Set Socket1 = New Socket
but i need this socket load multiple number, say 10 sockets
Attached Files
Mar 10th, 2011, 12:25 PM
#6
Re: using array of class module in form load
Use a collection. That's what they are for. You can not make an array of classes in VB6 or earlier. If you really insist on an array of classes then you need to switch to .NET.
VB6 Library
If I helped you then please help me and rate my post!
If you solved your problem, then please mark the post resolved
Mar 10th, 2011, 12:33 PM
#7
Re: using array of class module in form load
It is a very common mistake to wrap a Winsock control in a Class.
Rewrite this Class as a UserControl, which is what it should have been in the first place. Your problems will disappear.
Mar 10th, 2011, 01:58 PM
#8
Thread Starter
New Member
Re: using array of class module in form load
Originally Posted by
MarMan
Use a collection. That's what they are for.
Any tutorial for collection
Originally Posted by
dilettante
Rewrite this Class as a UserControl, which is what it should have been in the first place. Your problems will disappear.
and i have not wriiten that class, its written by Martin or Dazza for Specially Yahoo Programing
Mar 10th, 2011, 02:06 PM
#9
Re: using array of class module in form load
A collection is very easy to use.
Code:
Dim mcolSockets as Collection
Sub Form_Load()
Set mcolSockets = New Collection
mcolSockets.Add(Socket1)
End Sub
To use
Code:
mcolSockets(index).connect remote host, remote port
I don't have VB6 here so I had to write that without an IDE, it may not be perfect. Try using it then post your code if you have problems and we can help. dilettante is a VB6 coder so he can help as well.
VB6 Library
If I helped you then please help me and rate my post!
If you solved your problem, then please mark the post resolved
Mar 10th, 2011, 02:14 PM
#10
Re: using array of class module in form load
Using a Collection won't help much because you won't get control array event semantics.
A rewrite as a UserControl should be almost trivial. Most of the code can be copied right in without change. You could clean up some of that messy code at the same time.
Mar 10th, 2011, 03:33 PM
#11
Thread Starter
New Member
Re: using array of class module in form load
thank u, lets try. if solved I will inform u both
Posting Permissions
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
Forum Rules
Click Here to Expand Forum to Full Width