Serial Port Complete - Latest Microcontroller projects

(lily) #1

Chapter 10


 Imports System.Text


Friend stringBuffer As New StringBuilder

Dim newReceivedData As String

' Read received data into a String.

newReceivedData = myComPort.ReadExisting()

' Append the String to the StringBuilder object.

stringBuffer.Append(newReceivedData)

 using System.Text;


internal StringBuilder stringBuffer = new StringBuilder();

String newReceivedData;

// Read received data into a String.

newReceivedData = myComPort.ReadExisting();

// Append the String to the StringBuilder object.

stringBuffer.Append(newReceivedData);
To convert a StringBuilder object to a String, use the ToString property:

 Dim receivedText as String


receivedText = stringBuffer.ToString

 String receivedText;


receivedText = stringBuffer.ToString();
To clear a StringBuilder object, use the Remove method:

 stringBuffer.Remove(0, stringBuffer.Length)


 stringBuffer.Remove(0, stringBuffer.Length);

Free download pdf