I have a program that was created in vba, and I am working on attempting to convert it to work in vb.net. There are two functions that use vbUniCode and vbFromUnicode in a strConv.
The two functions are:
Code:
Private Function CommRead(Handle As Integer, DataBuffer As String, Size As Integer) As Integer
Dim bytesRead As Integer
Dim status As Integer
Dim buffer() As Byte
ReDim buffer(Size)
'Read from port
status = Relay_Functions.ReadFile(Handle, buffer(0), Size, bytesRead, 0)
If (status = 0) Then
CommRead = 0
Else
'Convert the array back in to string
DataBuffer = Left(StrConv(buffer, vbUnicode), Size)
CommRead = bytesRead
End If
End Function
Private Function CommWrite(Handle As Integer, Data As String) As Integer
Dim bytesWritten As Integer
Dim status As Integer
Dim buffer() As Byte
ReDim buffer(Len(Data))
buffer = StrConv(Data, vbFromUnicode)
'Write data to port
status = Relay_Functions.WriteFile(Handle, buffer(0), Len(Data), bytesWritten, 0)
If (status = 0) Then
CommWrite = 0
Else
CommWrite = bytesWritten
End If
End Function
Been trying to find an answer, but haven't been able to find anything sold that works in what the correct conversion is.