I’ve been given a VB6 program to convert to .NET, and while most of the VB6 specifics I’ve been able to figure out through googling, there’s one that I just have no idea about. Winsock is used, but the conversion utility replaced it with AxMSWinsockLib.AxWinsock. The old code references an index property, which AxMSWinsockLib.AxWinsock doesn’t have apparently, but I can’t figure out what it’s trying to do here. Any ideas?
Public Function PortsOpen(ByRef colWinsock As Collection, ByRef objWinsock As Winsock, ByVal LocalIPAddress As String) As Boolean
Dim Counter As Long
Dim sWS() As String
'Initial to open com. port
Counter = 0
If colWinsock.Count >= objWinsock.Index + 1 Then
sWS = colWinsock.Item(objWinsock.Index + 1)
In VB6 you are allowed to have an array of controls then reference them later using an Index. This behavior does not exist anymore in .Net
I believe in your case, the old VB6 used arrays of winsock to facilitate communication with other peers.
For example, if the original form in VB6 was designed by adding a WinSock control, then changing its name to mySock and then manually setting its Index property value to 0, it becomes mySock(0)
Later in the program, all you need to do to make another copy of the control is
so for you to change this logic to .Net, you will have to go around this by declaring the Winsock variable array totally from the code side without relaying on the design control.