Click here to Skip to main content
15,881,882 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Hello Dear All,

I am facing a problem with convert delphi code to vb.net... any body help me to get the solution please... please check the code below


Delphi
m_arTxBfx:Array [0..255] of Byte; //Output Buffer
m_arRxBfx:Array [0..255] of Byte; //Input Buffer


myPort.ClearBuffer(false,true);
myPort.Write(m_arTxBfx[0],m_InputLength+4);


Now I need to convert it vb.net

I have tried this way...
VB.NET
myPort.write(m_arTxBfx,m_InputLength,4)

but its showing error.......

Please Help me ...

Thanks in Advance

Moseur
Posted
Updated 23-Jul-23 1:42am
v4
Comments
Maciej Los 19-Jan-16 15:43pm    
What's the question?
What's an error?

1 solution

You have to write code from scratch, following the same logic. The class you need is System.IO.Ports.SerialPort:
SerialPort Class (System.IO.Ports)[^].

—SA
 
Share this answer
 
Comments
Maciej Los 19-Jan-16 16:23pm    
Short and to the point!
+5!
Sergey Alexandrovich Kryukov 19-Jan-16 16:27pm    
Thank you, Maciej.
—SA
CPallini 19-Jan-16 16:23pm    
Indeed, 5.
Sergey Alexandrovich Kryukov 19-Jan-16 16:28pm    
Thank you, Carlo.
—SA
Moseur 19-Jan-16 21:55pm    
Dear All,

Thanks for your help.


Imports System.IO.Ports
Imports System.Net.Sockets
Imports System.Text

Now in button event
I write this code:

m_arTxBfx(0) = &H7E
m_arTxBfx(1) = m_InputLength + 2
m_XOR = 255
m_SUM = 0
For i = 2 To m_InputLength + 1
m_XOR = m_XOR Xor m_arTxBfx(i)
m_SUM = m_SUM + m_arTxBfx(i)
Next
m_arTxBfx(m_InputLength + 2) = m_XOR
m_SUM = m_SUM + m_XOR
m_SUM = m_SUM And 255
m_arTxBfx(m_InputLength + 3) = m_SUM

temp = "Send: "
For i = 0 To m_InputLength + 3
'temp =Temp+Conversion .Hex (m_arTxBfx(i),2)+' '
Next
txtSend.Multiline = True

myres = 1
Dim inputlength As Integer = m_InputLength + 4

If mySerialPort.IsOpen = True Then
mySerialPort.DiscardInBuffer()
mySerialPort.Write(m_arTxBfx(0), inputlength)
End If

But Its showing error over the line (mySerialPort.Write(m_arTxBfx(0), inputlength)) Please help...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900