Results 1 to 11 of 11

Thread: using array of class module in form load

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2010
    Posts
    14

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

  2. #2
    Frenzied Member
    Join Date
    Jan 2010
    Location
    Connecticut
    Posts
    1,687

    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

  3. #3

    Thread Starter
    New Member
    Join Date
    Jan 2010
    Posts
    14

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

  4. #4
    Frenzied Member
    Join Date
    Jan 2010
    Location
    Connecticut
    Posts
    1,687

    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

  5. #5

    Thread Starter
    New Member
    Join Date
    Jan 2010
    Posts
    14

    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 Attached Files

  6. #6
    Frenzied Member
    Join Date
    Jan 2010
    Location
    Connecticut
    Posts
    1,687

    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

  7. #7
    PowerPoster dilettante's Avatar
    Join Date
    Feb 2006
    Posts
    24,487

    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.

  8. #8

    Thread Starter
    New Member
    Join Date
    Jan 2010
    Posts
    14

    Re: using array of class module in form load

    Quote Originally Posted by MarMan View Post
    Use a collection. That's what they are for.
    Any tutorial for collection


    Quote Originally Posted by dilettante View Post
    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

  9. #9
    Frenzied Member
    Join Date
    Jan 2010
    Location
    Connecticut
    Posts
    1,687

    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

  10. #10
    PowerPoster dilettante's Avatar
    Join Date
    Feb 2006
    Posts
    24,487

    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.

  11. #11

    Thread Starter
    New Member
    Join Date
    Jan 2010
    Posts
    14

    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
  •  



Click Here to Expand Forum to Full Width