Results 1 to 12 of 12

Thread: Need help migrating c++ .net to vb 6

Threaded View

  1. #3
    Fanatic Member
    Join Date
    Jan 2006
    Posts
    710

    Re: Need help migrating c++ .net to vb 6

    (via Instant VB):
    (by the way, the original code was C#, not C++)

    Code:
    Public Function Send(ByVal strSendData As String, ByVal num1 As Integer) As String
    	Dim text1 As String = Nothing
    	Dim buffer1 As Byte() = New Byte(&Hc350 - 1){}
    	Dim address1 As IPAddress = IPAddress.Parse(Me.strIPAddress)
    	Dim point1 As IPEndPoint = New IPEndPoint(address1, &H2724)
    	Dim socket1 As Socket = New Socket(2, 1, 6)
    	Try
    		Dim num4 As Integer
    		Dim buffer2 As Byte() = Encoding.get_Default().GetBytes(strSendData)
    		Dim num2 As Integer = buffer2.Length
    		Dim buffer3 As Byte() = BitConverter.GetBytes(num2 + 1)
    		Dim buffer4 As Byte() = New Byte(num2 + 5 - 1){}
    		socket1.Connect(point1)
    		buffer4(0) = buffer3(3)
    		buffer4(1) = buffer3(2)
    		buffer4(2) = buffer3(1)
    		buffer4(3) = buffer3(0)
    		buffer4(4) = CByte(num1)
    		For num3 As Integer = 5 To (num2 + 5) - 1
    			buffer4(num3) = buffer2(num3 - 5)
    		Next num3
    		socket1.Send(buffer4)
    		GoTo Label_00B2
    Label_00B2:
    		num4 = socket1.Receive(buffer1)
    		Dim num5 As Integer = (((((buffer1(0) << &H18) Or buffer1(1)) << &H10) Or buffer1(2)) << 8) Or (buffer1(3) + 4)
    		If num5 <> num4 Then
    			GoTo Label_00B2
    		End If
    		text1 = Encoding.get_Default().GetString(buffer1, 5, num4)
    	Catch e1 As Exception
    		text1 = "Error"
    	Finally
    		socket1.Shutdown(2)
    		socket1.Close()
    	End Try
    	Return text1
    End Function
    Last edited by David Anton; Apr 15th, 2007 at 08:43 AM. Reason: added a note
    David Anton
    Convert between VB, C#, C++, & Java
    www.tangiblesoftwaresolutions.com

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