Hello,
I have some problem I cannot to solve.
I am using MSWinsock library for TCPIP connection. It is very simple.
What I have done:
1. I created new project
2. Added MSWinsock library
3. Than I used drag-drop function to put component from ToolBox on Form.
Now in source code on top menu I have many events I can choose. (See attached photo)
Simple code is following.
Code:
Public Class Form1
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
TCPIP.RemoteHost = "127.0.0.1"
TCPIP.RemotePort = 9100
TCPIP.Protocol = MSWinsockLib.ProtocolConstants.sckTCPProtocol
TCPIP.Connect()
End Sub
Private Sub TCPIP_DataArrival(sender As Object, e As AxMSWinsockLib.DMSWinsockControlEvents_DataArrivalEvent) Handles TCPIP.DataArrival
End Sub
End Class
When I start program and launch any TCPIP server on port 9100 I have connection. When I send any message, TCPIP_DataArrival sub is running.
But I would like to do this without drag-drop function.
Just to do this only with source code.
I have done it as following:
Code:
Imports MSWinsockLib
Public Class Form1
Public TCPIP As MSWinsockLib.Winsock
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
TCPIP.RemoteHost = "127.0.0.1"
TCPIP.RemotePort = 9100
TCPIP.Protocol = ProtocolConstants.sckTCPProtocol
TCPIP.Connect()
End Sub
Private Sub TCPIP_DataArrival(sender As Object, e As AxMSWinsockLib.DMSWinsockControlEvents_DataArrivalEvent) Handles TCPIP.DataArrival
End Sub
End Class
Connection is working, but I don't know how to define DataArrival Event. I have error in syntax. See attached photo.
It is just event like in many libraries, but I dont know how to programm it
I was trying Public WithEvents TCPIP As MSWinsockLib.Winsock but without success.
I was trying also to do this like this way.
Code:
TMR = New System.Timers.Timer
TMR.Interval = 1000
TMR.Stop()
AddHandler TMR.Elapsed, AddressOf TMR_tick
Private Sub TMR_tick(ByVal source As Object, ByVal e As System.Timers.ElapsedEventArgs)
End Sub
Can somebody help me?
Thanks in advance.