winsock VBA

rpaulson

Well-known Member
Joined
Oct 4, 2007
Messages
1,411
download example from here
http://www.ostrosoft.com/oswinsck.asp#inst

I did register the DLL and when I run the code on the form it shows up in the view window.

I prefer not want to use the form.

I would like each line of data to go to the next row in column "A".
this is beyond my cabability.

Anyone know what i'm doing wrong?


my modified code.
Rich (BB code):
'VBA sample for OstroSoft Winsock Component
'written by Igor Ostrovsky (OstroSoft)
'
'Permanent URL for this project is
'http://www.ostrosoft.com/oswinsck/oswinsck_vba.asp
'
'For more information about OstroSoft Winsock Component go to
'http://www.ostrosoft.com/oswinsck.asp
'
'OstroSoft Winsock Component is available for download at
'http://www.ostrosoft.com/download/oswinsck.zip
'
'Questions, suggestions, comments - email to info@ostrosoft.com
'or submit a form at http://www.ostrosoft.com/contact.asp

Option Explicit
Dim sPage As String
Dim WithEvents wsTCP As oswinsck.Winsock  'THIS LINE IS RED IN MY MODULE

Sub init()
  Dim sServer As String
  Dim nPort As Long
  
  wsTCP.Connect "sprint.wrgscoring.com", 50000
  Exit Sub

End Sub

Sub wsTCP_OnDataArrival(ByVal bytesTotal As Long)
  Dim sBuffer As String, r As Integer
  wsTCP.GetData sBuffer
  txtSource = txtSource & sBuffer
  r = 1
  Cells(r, "A") = sBuffer
  
  r = r + 1
End Sub

Tia,

Ross
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
I'm no star in external procedures, but you are trying to set upp a variable with the structure of oswinsck.Winsock

But the VBA doesn't know what oswinsck.Winsock looks like so you need to refer it to a library where it can find this definition. This is done with a Declare statement, i think.
 
Upvote 0
Dim WithEvents wsTCP As oswinsck.Winsock 'THIS LINE IS RED IN MY MODULE

Where have you put the code? WithEvents is not valid in a standard module, so the code must go in a sheet, class or userform module. Click Debug - Compile and this reason for the red line is revealed.

Also, in your VB project, make sure you have a reference to the Winsock component in Tools - References.
 
Upvote 0

Forum statistics

Threads
1,223,248
Messages
6,171,027
Members
452,374
Latest member
keccles

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top