Writes specified number of bytes to serial port.
| Visual Basic | -
|
|---|---|
| Visual C++ (MFC) | long Write(long DataBuffer, long BytesToWrite);
|
| Visual C++ (#import) | LONG Write(LONG DataBuffer, LONG BytesToWrite);
|
DataBuffer
[in] Buffer of characters to be written. Use type-casting to convert it from void* or char*.
BytesToWrite
[in] Number of bytes to write to serial port.
Number of bytes written to serial port. It can write fewer bytes than requested; the return value must be noted, and the reminder of the operation should be retried when possible.
The method may throw exception. Use GetLastError method to get the error code.
In Visual Basic use WriteArray.
char *WriteBuffer = "Data to write";
try
{
m_SPCControl1.Write((LONG)WriteBuffer, strlen(WriteBuffer));
}
catch(COleDispatchException* E)
{
MessageBox(E->m_strDescription, mbCaption, MB_OK | MB_ICONERROR);
}