home *** CD-ROM | disk | FTP | other *** search
/ ftp.tcs3.com / ftp.tcs3.com.tar / ftp.tcs3.com / DRIVERS / Audio / Office2010 / InfoPath.en-us / InfLR.cab / FL_ReadDatafromaSerialPort_snippet_142596_ENU____.3643236F_FC70_11D3_A536_0090278A1BB8 < prev    next >
Extensible Markup Language  |  2008-09-17  |  1KB  |  39 lines

  1. <?xml version="1.0"?>
  2. <CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
  3.   <CodeSnippet Format="1.0.0">
  4.     <Header>
  5.       <Title>Read Data from a Serial Port</Title>
  6.       <Author>Microsoft Corporation</Author>
  7.       <Description>Reads Data from a Serial Port</Description>
  8.       <Shortcut>conReadPort</Shortcut>
  9.     </Header>
  10.     <Snippet>
  11.       <Imports>
  12.     <Import>
  13.       <Namespace>System.Text</Namespace>
  14.     </Import>
  15.     <Import>
  16.       <Namespace>System.IO.Ports</Namespace>
  17.     </Import>
  18.       </Imports>
  19.       <Declarations>
  20.         <Literal>
  21.           <ID>COM</ID>
  22.           <ToolTip>Replace with the name of the COM port.</ToolTip>
  23.           <Default>"COM1"</Default>
  24.         </Literal>
  25.       </Declarations>
  26.       <Code Language="VB" Kind="method body"><![CDATA[Dim buffer As New StringBuilder()
  27. Using comPort As SerialPort = My.Computer.Ports.OpenSerialPort($COM$)
  28.     Do
  29.         Dim line As String = comPort.ReadLine()
  30.         If line Is Nothing Then
  31.             Exit Do
  32.         Else
  33.             buffer.AppendLine(line)
  34.         End If
  35.     Loop
  36. End Using]]></Code>
  37.     </Snippet>
  38.   </CodeSnippet>
  39. </CodeSnippets>