Results 1 to 2 of 2

Thread: HELP! Plz! Events in a class...

  1. #1

    Thread Starter
    Member
    Join Date
    Jan 2002
    Location
    New Jersey
    Posts
    39

    HELP! Plz! Events in a class...

    Ok... I created a COM object that simply creates figures for CompanyA... There is a twist. I have (as seen in previous posts) referenced Winsock because in order to get certain information I need to call another server.

    Here in lies the problem..

    I have one function in the class
    Now, I get all of my numbers EXCEPT for the winsock numbers.
    because the function is ending before all of the winsock_events are completing...

    VB Code:
    1. Public Function GetData() as string
    2.  
    3.     Dim sData as string 'this holds all of the data needed to send back
    4.  
    5.     Set oWinSock = New Winsock
    6.     gbDataSent = False
    7.     oClient.Close
    8.  
    9.     'This section was way to long but it produces the sData variable
    10.  
    11.     oWinSock.RemoteHost = HOST_IP
    12.     oWinSock.RemotePort = HOST_PORT
    13.     oWinSock.Connect
    14.  
    15.     sData = sData & gsTCPData 'gstcpdata is a global variable that is set in the winsock_DataArrival() event when it receives a response.
    16.  
    17.     GetData = sData
    18. End Function

    The problem is that after the oWinsock.Connect runs the function completes and doesn't wait for teh events to fire.

    BUT...

    If I put a msgbox immediately after the oWinSock.Connect, the data will return perfectly... but it's impossible for the users to do this...

    ne ideas???

  2. #2
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    You could either set a flag in one of the winsock events and loop until it is set and then move on in the function or you can loop and maybe use the connection state to move on.

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