Using the VB6 Winsock control in VB.NET the GetData(byRef Data as Object) method of the control returns an Object.
I have used this code that works but am not familiar with .NET arrays/object/conversions...
Private Sub wskSocketPlus_D ataArrival(ByVa l sender As Object, ByVal e As AxMSWinsockLib. DMSWinsockContr olEvents_DataAr rivalEvent) Handles wskSocketPlus.D ataArrival
Dim o As Object
wskSocketPlus.G etData(o)
Dim incomingDataArr ay() As Byte
incomingDataArr ay = CType(o, System.Byte())
Dim Buffer As New StringBuilder
Dim b As Byte
For element As Integer = 0 To incomingDataArr ay.Length - 1
b = Convert.ToByte( incomingDataArr ay.GetValue(ele ment))
Buffer.Append(C hr(b))
Next element
MessageBox.Show (Buffer.ToStrin g)
End Sub
I was told I should use string builder as it is fatser than concatination. The datapackets are around a few thosand bytes. Any suggestions as to a more correct set of conversions to give me a resulting string of the incoming Object data?
thanks, Jarrod
I have used this code that works but am not familiar with .NET arrays/object/conversions...
Private Sub wskSocketPlus_D ataArrival(ByVa l sender As Object, ByVal e As AxMSWinsockLib. DMSWinsockContr olEvents_DataAr rivalEvent) Handles wskSocketPlus.D ataArrival
Dim o As Object
wskSocketPlus.G etData(o)
Dim incomingDataArr ay() As Byte
incomingDataArr ay = CType(o, System.Byte())
Dim Buffer As New StringBuilder
Dim b As Byte
For element As Integer = 0 To incomingDataArr ay.Length - 1
b = Convert.ToByte( incomingDataArr ay.GetValue(ele ment))
Buffer.Append(C hr(b))
Next element
MessageBox.Show (Buffer.ToStrin g)
End Sub
I was told I should use string builder as it is fatser than concatination. The datapackets are around a few thosand bytes. Any suggestions as to a more correct set of conversions to give me a resulting string of the incoming Object data?
thanks, Jarrod
Comment