Repository navigation
Expand file tree
/
Copy pathPorts.xml
More file actions
562 lines (463 loc) · 32.3 KB
/
Copy pathPorts.xml
File metadata and controls
562 lines (463 loc) · 32.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
<Type Name="Ports" FullName="Microsoft.VisualBasic.Devices.Ports">
<TypeSignature Language="C#" Value="public class Ports" />
<TypeSignature Language="ILAsm" Value=".class public auto ansi Ports extends System.Object" />
<TypeSignature Language="DocId" Value="T:Microsoft.VisualBasic.Devices.Ports" />
<TypeSignature Language="VB.NET" Value="Public Class Ports" />
<TypeSignature Language="C++ CLI" Value="public ref class Ports" />
<AssemblyInfo>
<AssemblyName>Microsoft.VisualBasic</AssemblyName>
<AssemblyVersion>10.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Base>
<BaseTypeName>System.Object</BaseTypeName>
</Base>
<Interfaces />
<Docs>
<summary>Provides a property and a method for accessing the computer's serial ports.</summary>
<remarks>
<format type="text/markdown"><] serial port class, <xref:System.IO.Ports.SerialPort>.
The following table lists examples of tasks involving the `My.Computer.Ports` object.
|To|See|
|-|-|
|Dial a modem attached to a serial port|[How to: Dial Modems Attached to Serial Ports](~/docs/visual-basic/developing-apps/programming/computer-resources/how-to-dial-modems-attached-to-serial-ports.md)|
|Send a string to a serial port|[How to: Send Strings to Serial Ports](~/docs/visual-basic/developing-apps/programming/computer-resources/how-to-send-strings-to-serial-ports.md)|
|Receive strings from a serial port|[How to: Receive Strings From Serial Ports](~/docs/visual-basic/developing-apps/programming/computer-resources/how-to-receive-strings-from-serial-ports.md)|
|Show available serial ports|[How to: Show Available Serial Ports](~/docs/visual-basic/developing-apps/programming/computer-resources/how-to-show-available-serial-ports.md)|
## Availability by Project Type
|Project type|Available|
|-|-|
|Windows Application|**Yes**|
|Class Library|**Yes**|
|Console Application|**Yes**|
|Windows Control Library|**Yes**|
|Web Control Library|No|
|Windows Service|**Yes**|
|Web Site|No|
## Examples
This example describes how to send strings to the computer's `COM1` serial port.
The `Using` block allows the application to close the serial port even if it generates an exception. All code that manipulates the serial port should appear within this block, or within a `Try...Catch...Finally` block with a call to use the <xref:System.IO.Ports.SerialPort.Close%2A> method.
The <xref:System.IO.Ports.SerialPort.WriteLine%2A> method sends the data to the serial port.
[!code-vb[VbVbalrMyComputer#33](~/samples/snippets/visualbasic/VS_Snippets_VBCSharp/VbVbalrMyComputer/VB/Class2.vb#33)]
For more information, see [How to: Send Strings to Serial Ports](~/docs/visual-basic/developing-apps/programming/computer-resources/how-to-send-strings-to-serial-ports.md).
]]></format>
</remarks>
</Docs>
<Members>
<Member MemberName=".ctor">
<MemberSignature Language="C#" Value="public Ports ();" />
<MemberSignature Language="ILAsm" Value=".method public specialname rtspecialname instance void .ctor() cil managed" />
<MemberSignature Language="DocId" Value="M:Microsoft.VisualBasic.Devices.Ports.#ctor" />
<MemberSignature Language="VB.NET" Value="Public Sub New ()" />
<MemberSignature Language="C++ CLI" Value="public:
 Ports();" />
<MemberType>Constructor</MemberType>
<AssemblyInfo>
<AssemblyName>Microsoft.VisualBasic</AssemblyName>
<AssemblyVersion>10.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Parameters />
<Docs>
<summary>Initializes a new instance of the <see cref="T:Microsoft.VisualBasic.Devices.Ports" /> class.</summary>
<remarks>To be added.</remarks>
</Docs>
</Member>
<MemberGroup MemberName="OpenSerialPort">
<AssemblyInfo>
<AssemblyName>Microsoft.VisualBasic</AssemblyName>
<AssemblyVersion>10.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Docs>
<summary>Creates and opens a <see cref="T:System.IO.Ports.SerialPort" /> object.</summary>
</Docs>
</MemberGroup>
<Member MemberName="OpenSerialPort">
<MemberSignature Language="C#" Value="public System.IO.Ports.SerialPort OpenSerialPort (string portName);" />
<MemberSignature Language="ILAsm" Value=".method public instance class System.IO.Ports.SerialPort OpenSerialPort(string portName) cil managed" />
<MemberSignature Language="DocId" Value="M:Microsoft.VisualBasic.Devices.Ports.OpenSerialPort(System.String)" />
<MemberSignature Language="VB.NET" Value="Public Function OpenSerialPort (portName As String) As SerialPort" />
<MemberSignature Language="C++ CLI" Value="public:
 System::IO::Ports::SerialPort ^ OpenSerialPort(System::String ^ portName);" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>Microsoft.VisualBasic</AssemblyName>
<AssemblyVersion>10.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.IO.Ports.SerialPort</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="portName" Type="System.String" />
</Parameters>
<Docs>
<param name="portName">
<see langword="String" />. Required. Name of the port to open.</param>
<summary>Creates and opens a <see cref="T:System.IO.Ports.SerialPort" /> object.</summary>
<returns>An open <see cref="T:System.IO.Ports.SerialPort" /> object, configured with the supplied arguments.</returns>
<remarks>
<format type="text/markdown"><|
|Send a string to serial port|[How to: Send Strings to Serial Ports](~/docs/visual-basic/developing-apps/programming/computer-resources/how-to-send-strings-to-serial-ports.md)|
|Receive strings from a serial port|[How to: Receive Strings From Serial Ports](~/docs/visual-basic/developing-apps/programming/computer-resources/how-to-receive-strings-from-serial-ports.md)|
## Availability by Project Type
|Project type|Available|
|-|-|
|Windows Application|**Yes**|
|Class Library|**Yes**|
|Console Application|**Yes**|
|Windows Control Library|**Yes**|
|Web Control Library|No|
|Windows Service|**Yes**|
|Web Site|No|
## Examples
This example describes how to send strings to the computer's `COM1` serial port.
The `Using` block allows the application to close the serial port even if it generates an exception. All code that manipulates the serial port should appear within this block, or within a `Try...Catch...Finally` block with a call to use the <xref:System.IO.Ports.SerialPort.Close%2A> method.
The <xref:System.IO.Ports.SerialPort.WriteLine%2A> method sends the data to the serial port.
[!code-vb[VbVbalrMyComputer#33](~/samples/snippets/visualbasic/VS_Snippets_VBCSharp/VbVbalrMyComputer/VB/Class2.vb#33)]
For more information, see [How to: Send Strings to Serial Ports](~/docs/visual-basic/developing-apps/programming/computer-resources/how-to-send-strings-to-serial-ports.md).
]]></format>
</remarks>
<exception cref="T:System.ArgumentNullException">
<paramref name="portName" /> is <see langword="Nothing" /> or an empty string.</exception>
<altmember cref="P:Microsoft.VisualBasic.Devices.Ports.SerialPortNames" />
<altmember cref="T:System.IO.Ports.Parity" />
<altmember cref="T:System.IO.Ports.StopBits" />
<altmember cref="T:System.IO.Ports.SerialPort" />
</Docs>
</Member>
<Member MemberName="OpenSerialPort">
<MemberSignature Language="C#" Value="public System.IO.Ports.SerialPort OpenSerialPort (string portName, int baudRate);" />
<MemberSignature Language="ILAsm" Value=".method public instance class System.IO.Ports.SerialPort OpenSerialPort(string portName, int32 baudRate) cil managed" />
<MemberSignature Language="DocId" Value="M:Microsoft.VisualBasic.Devices.Ports.OpenSerialPort(System.String,System.Int32)" />
<MemberSignature Language="VB.NET" Value="Public Function OpenSerialPort (portName As String, baudRate As Integer) As SerialPort" />
<MemberSignature Language="C++ CLI" Value="public:
 System::IO::Ports::SerialPort ^ OpenSerialPort(System::String ^ portName, int baudRate);" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>Microsoft.VisualBasic</AssemblyName>
<AssemblyVersion>10.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.IO.Ports.SerialPort</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="portName" Type="System.String" />
<Parameter Name="baudRate" Type="System.Int32" />
</Parameters>
<Docs>
<param name="portName">
<see langword="String" />. Required. Name of the port to open.</param>
<param name="baudRate">
<see langword="Integer" />. Baud rate of the port.</param>
<summary>Creates and opens a <see cref="T:System.IO.Ports.SerialPort" /> object.</summary>
<returns>An open <see cref="T:System.IO.Ports.SerialPort" /> object, configured with the supplied arguments.</returns>
<remarks>
<format type="text/markdown"><|
|Send a string to serial port|[How to: Send Strings to Serial Ports](~/docs/visual-basic/developing-apps/programming/computer-resources/how-to-send-strings-to-serial-ports.md)|
|Receive strings from a serial port|[How to: Receive Strings From Serial Ports](~/docs/visual-basic/developing-apps/programming/computer-resources/how-to-receive-strings-from-serial-ports.md)|
## Availability by Project Type
|Project type|Available|
|-|-|
|Windows Application|**Yes**|
|Class Library|**Yes**|
|Console Application|**Yes**|
|Windows Control Library|**Yes**|
|Web Control Library|No|
|Windows Service|**Yes**|
|Web Site|No|
## Examples
This example describes how to send strings to the computer's `COM1` serial port.
The `Using` block allows the application to close the serial port even if it generates an exception. All code that manipulates the serial port should appear within this block, or within a `Try...Catch...Finally` block with a call to use the <xref:System.IO.Ports.SerialPort.Close%2A> method.
The <xref:System.IO.Ports.SerialPort.WriteLine%2A> method sends the data to the serial port.
[!code-vb[VbVbalrMyComputer#33](~/samples/snippets/visualbasic/VS_Snippets_VBCSharp/VbVbalrMyComputer/VB/Class2.vb#33)]
For more information, see [How to: Send Strings to Serial Ports](~/docs/visual-basic/developing-apps/programming/computer-resources/how-to-send-strings-to-serial-ports.md).
]]></format>
</remarks>
<exception cref="T:System.ArgumentNullException">
<paramref name="portName" /> is <see langword="Nothing" /> or an empty string.</exception>
<exception cref="T:System.ArgumentException">
<paramref name="baudRate" /> is less than or equal to zero.</exception>
<altmember cref="P:Microsoft.VisualBasic.Devices.Ports.SerialPortNames" />
<altmember cref="T:System.IO.Ports.Parity" />
<altmember cref="T:System.IO.Ports.StopBits" />
<altmember cref="T:System.IO.Ports.SerialPort" />
</Docs>
</Member>
<Member MemberName="OpenSerialPort">
<MemberSignature Language="C#" Value="public System.IO.Ports.SerialPort OpenSerialPort (string portName, int baudRate, System.IO.Ports.Parity parity);" />
<MemberSignature Language="ILAsm" Value=".method public instance class System.IO.Ports.SerialPort OpenSerialPort(string portName, int32 baudRate, valuetype System.IO.Ports.Parity parity) cil managed" />
<MemberSignature Language="DocId" Value="M:Microsoft.VisualBasic.Devices.Ports.OpenSerialPort(System.String,System.Int32,System.IO.Ports.Parity)" />
<MemberSignature Language="C++ CLI" Value="public:
 System::IO::Ports::SerialPort ^ OpenSerialPort(System::String ^ portName, int baudRate, System::IO::Ports::Parity parity);" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>Microsoft.VisualBasic</AssemblyName>
<AssemblyVersion>10.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.IO.Ports.SerialPort</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="portName" Type="System.String" />
<Parameter Name="baudRate" Type="System.Int32" />
<Parameter Name="parity" Type="System.IO.Ports.Parity" />
</Parameters>
<Docs>
<param name="portName">
<see langword="String" />. Required. Name of the port to open.</param>
<param name="baudRate">
<see langword="Integer" />. Baud rate of the port.</param>
<param name="parity">
<see cref="T:System.IO.Ports.Parity" />. Parity of the port.</param>
<summary>Creates and opens a <see cref="T:System.IO.Ports.SerialPort" /> object.</summary>
<returns>An open <see cref="T:System.IO.Ports.SerialPort" /> object, configured with the supplied arguments.</returns>
<remarks>
<format type="text/markdown"><|
|Send a string to serial port|[How to: Send Strings to Serial Ports](~/docs/visual-basic/developing-apps/programming/computer-resources/how-to-send-strings-to-serial-ports.md)|
|Receive strings from a serial port|[How to: Receive Strings From Serial Ports](~/docs/visual-basic/developing-apps/programming/computer-resources/how-to-receive-strings-from-serial-ports.md)|
## Availability by Project Type
|Project type|Available|
|-|-|
|Windows Application|**Yes**|
|Class Library|**Yes**|
|Console Application|**Yes**|
|Windows Control Library|**Yes**|
|Web Control Library|No|
|Windows Service|**Yes**|
|Web Site|No|
## Examples
This example describes how to send strings to the computer's `COM1` serial port.
The `Using` block allows the application to close the serial port even if it generates an exception. All code that manipulates the serial port should appear within this block, or within a `Try...Catch...Finally` block with a call to use the <xref:System.IO.Ports.SerialPort.Close%2A> method.
The <xref:System.IO.Ports.SerialPort.WriteLine%2A> method sends the data to the serial port.
[!code-vb[VbVbalrMyComputer#33](~/samples/snippets/visualbasic/VS_Snippets_VBCSharp/VbVbalrMyComputer/VB/Class2.vb#33)]
For more information, see [How to: Send Strings to Serial Ports](~/docs/visual-basic/developing-apps/programming/computer-resources/how-to-send-strings-to-serial-ports.md).
]]></format>
</remarks>
<exception cref="T:System.ArgumentNullException">
<paramref name="portName" /> is <see langword="Nothing" /> or an empty string.</exception>
<exception cref="T:System.ArgumentException">
<paramref name="baudRate" /> is less than or equal to zero.</exception>
<exception cref="T:System.ComponentModel.InvalidEnumArgumentException">
<paramref name="parity" /> is not one of the <see cref="T:System.IO.Ports.Parity" /> enumeration values.</exception>
<altmember cref="P:Microsoft.VisualBasic.Devices.Ports.SerialPortNames" />
<altmember cref="T:System.IO.Ports.Parity" />
<altmember cref="T:System.IO.Ports.StopBits" />
<altmember cref="T:System.IO.Ports.SerialPort" />
</Docs>
</Member>
<Member MemberName="OpenSerialPort">
<MemberSignature Language="C#" Value="public System.IO.Ports.SerialPort OpenSerialPort (string portName, int baudRate, System.IO.Ports.Parity parity, int dataBits);" />
<MemberSignature Language="ILAsm" Value=".method public instance class System.IO.Ports.SerialPort OpenSerialPort(string portName, int32 baudRate, valuetype System.IO.Ports.Parity parity, int32 dataBits) cil managed" />
<MemberSignature Language="DocId" Value="M:Microsoft.VisualBasic.Devices.Ports.OpenSerialPort(System.String,System.Int32,System.IO.Ports.Parity,System.Int32)" />
<MemberSignature Language="C++ CLI" Value="public:
 System::IO::Ports::SerialPort ^ OpenSerialPort(System::String ^ portName, int baudRate, System::IO::Ports::Parity parity, int dataBits);" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>Microsoft.VisualBasic</AssemblyName>
<AssemblyVersion>10.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.IO.Ports.SerialPort</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="portName" Type="System.String" />
<Parameter Name="baudRate" Type="System.Int32" />
<Parameter Name="parity" Type="System.IO.Ports.Parity" />
<Parameter Name="dataBits" Type="System.Int32" />
</Parameters>
<Docs>
<param name="portName">
<see langword="String" />. Required. Name of the port to open.</param>
<param name="baudRate">
<see langword="Integer" />. Baud rate of the port.</param>
<param name="parity">
<see cref="T:System.IO.Ports.Parity" />. Parity of the port.</param>
<param name="dataBits">
<see langword="Integer" />. Data-bit setting of the port.</param>
<summary>Creates and opens a <see cref="T:System.IO.Ports.SerialPort" /> object.</summary>
<returns>An open <see cref="T:System.IO.Ports.SerialPort" /> object, configured with the supplied arguments.</returns>
<remarks>
<format type="text/markdown"><|
|Send a string to serial port|[How to: Send Strings to Serial Ports](~/docs/visual-basic/developing-apps/programming/computer-resources/how-to-send-strings-to-serial-ports.md)|
|Receive strings from a serial port|[How to: Receive Strings From Serial Ports](~/docs/visual-basic/developing-apps/programming/computer-resources/how-to-receive-strings-from-serial-ports.md)|
## Availability by Project Type
|Project type|Available|
|-|-|
|Windows Application|**Yes**|
|Class Library|**Yes**|
|Console Application|**Yes**|
|Windows Control Library|**Yes**|
|Web Control Library|No|
|Windows Service|**Yes**|
|Web Site|No|
## Examples
This example describes how to send strings to the computer's `COM1` serial port.
The `Using` block allows the application to close the serial port even if it generates an exception. All code that manipulates the serial port should appear within this block, or within a `Try...Catch...Finally` block with a call to use the <xref:System.IO.Ports.SerialPort.Close%2A> method.
The <xref:System.IO.Ports.SerialPort.WriteLine%2A> method sends the data to the serial port.
[!code-vb[VbVbalrMyComputer#33](~/samples/snippets/visualbasic/VS_Snippets_VBCSharp/VbVbalrMyComputer/VB/Class2.vb#33)]
For more information, see [How to: Send Strings to Serial Ports](~/docs/visual-basic/developing-apps/programming/computer-resources/how-to-send-strings-to-serial-ports.md).
]]></format>
</remarks>
<exception cref="T:System.ArgumentNullException">
<paramref name="portName" /> is <see langword="Nothing" /> or an empty string.</exception>
<exception cref="T:System.ArgumentException">
<paramref name="dataBits" /> is less than or equal to zero.</exception>
<exception cref="T:System.ComponentModel.InvalidEnumArgumentException">
<paramref name="parity" /> is not one of the <see cref="T:System.IO.Ports.Parity" /> enumeration values.</exception>
<altmember cref="P:Microsoft.VisualBasic.Devices.Ports.SerialPortNames" />
<altmember cref="T:System.IO.Ports.Parity" />
<altmember cref="T:System.IO.Ports.StopBits" />
<altmember cref="T:System.IO.Ports.SerialPort" />
</Docs>
</Member>
<Member MemberName="OpenSerialPort">
<MemberSignature Language="C#" Value="public System.IO.Ports.SerialPort OpenSerialPort (string portName, int baudRate, System.IO.Ports.Parity parity, int dataBits, System.IO.Ports.StopBits stopBits);" />
<MemberSignature Language="ILAsm" Value=".method public instance class System.IO.Ports.SerialPort OpenSerialPort(string portName, int32 baudRate, valuetype System.IO.Ports.Parity parity, int32 dataBits, valuetype System.IO.Ports.StopBits stopBits) cil managed" />
<MemberSignature Language="DocId" Value="M:Microsoft.VisualBasic.Devices.Ports.OpenSerialPort(System.String,System.Int32,System.IO.Ports.Parity,System.Int32,System.IO.Ports.StopBits)" />
<MemberSignature Language="C++ CLI" Value="public:
 System::IO::Ports::SerialPort ^ OpenSerialPort(System::String ^ portName, int baudRate, System::IO::Ports::Parity parity, int dataBits, System::IO::Ports::StopBits stopBits);" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>Microsoft.VisualBasic</AssemblyName>
<AssemblyVersion>10.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.IO.Ports.SerialPort</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="portName" Type="System.String" />
<Parameter Name="baudRate" Type="System.Int32" />
<Parameter Name="parity" Type="System.IO.Ports.Parity" />
<Parameter Name="dataBits" Type="System.Int32" />
<Parameter Name="stopBits" Type="System.IO.Ports.StopBits" />
</Parameters>
<Docs>
<param name="portName">
<see langword="String" />. Required. Name of the port to open.</param>
<param name="baudRate">
<see langword="Integer" />. Baud rate of the port.</param>
<param name="parity">
<see cref="T:System.IO.Ports.Parity" />. Parity of the port.</param>
<param name="dataBits">
<see langword="Integer" />. Data-bit setting of the port.</param>
<param name="stopBits">
<see cref="T:System.IO.Ports.StopBits" />. Stop-bit setting of the port.</param>
<summary>Creates and opens a <see cref="T:System.IO.Ports.SerialPort" /> object.</summary>
<returns>An open <see cref="T:System.IO.Ports.SerialPort" /> object, configured with the supplied arguments.</returns>
<remarks>
<format type="text/markdown"><|
|Send a string to serial port|[How to: Send Strings to Serial Ports](~/docs/visual-basic/developing-apps/programming/computer-resources/how-to-send-strings-to-serial-ports.md)|
|Receive strings from a serial port|[How to: Receive Strings From Serial Ports](~/docs/visual-basic/developing-apps/programming/computer-resources/how-to-receive-strings-from-serial-ports.md)|
## Availability by Project Type
|Project type|Available|
|-|-|
|Windows Application|**Yes**|
|Class Library|**Yes**|
|Console Application|**Yes**|
|Windows Control Library|**Yes**|
|Web Control Library|No|
|Windows Service|**Yes**|
|Web Site|No|
## Examples
This example describes how to send strings to the computer's `COM1` serial port.
The `Using` block allows the application to close the serial port even if it generates an exception. All code that manipulates the serial port should appear within this block, or within a `Try...Catch...Finally` block with a call to use the <xref:System.IO.Ports.SerialPort.Close%2A> method.
The <xref:System.IO.Ports.SerialPort.WriteLine%2A> method sends the data to the serial port.
[!code-vb[VbVbalrMyComputer#33](~/samples/snippets/visualbasic/VS_Snippets_VBCSharp/VbVbalrMyComputer/VB/Class2.vb#33)]
For more information, see [How to: Send Strings to Serial Ports](~/docs/visual-basic/developing-apps/programming/computer-resources/how-to-send-strings-to-serial-ports.md).
]]></format>
</remarks>
<exception cref="T:System.ArgumentNullException">
<paramref name="portName" /> is <see langword="Nothing" /> or an empty string.</exception>
<exception cref="T:System.ArgumentException">
<paramref name="dataBits" /> is less than or equal to zero.</exception>
<exception cref="T:System.ComponentModel.InvalidEnumArgumentException">
<paramref name="stopBits" /> is not one of the <see cref="T:System.IO.Ports.StopBits" /> enumeration values.</exception>
<altmember cref="P:Microsoft.VisualBasic.Devices.Ports.SerialPortNames" />
<altmember cref="T:System.IO.Ports.Parity" />
<altmember cref="T:System.IO.Ports.StopBits" />
<altmember cref="T:System.IO.Ports.SerialPort" />
</Docs>
</Member>
<Member MemberName="SerialPortNames">
<MemberSignature Language="C#" Value="public System.Collections.ObjectModel.ReadOnlyCollection<string> SerialPortNames { get; }" />
<MemberSignature Language="ILAsm" Value=".property instance class System.Collections.ObjectModel.ReadOnlyCollection`1<string> SerialPortNames" />
<MemberSignature Language="DocId" Value="P:Microsoft.VisualBasic.Devices.Ports.SerialPortNames" />
<MemberSignature Language="VB.NET" Value="Public ReadOnly Property SerialPortNames As ReadOnlyCollection(Of String)" />
<MemberSignature Language="C++ CLI" Value="public:
 property System::Collections::ObjectModel::ReadOnlyCollection<System::String ^> ^ SerialPortNames { System::Collections::ObjectModel::ReadOnlyCollection<System::String ^> ^ get(); };" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>Microsoft.VisualBasic</AssemblyName>
<AssemblyVersion>10.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Collections.ObjectModel.ReadOnlyCollection<System.String></ReturnType>
</ReturnValue>
<Docs>
<summary>Gets a collection of the names of the serial ports on the computer.</summary>
<value>A collection of the names of the serial ports on the computer.</value>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The `My.Computer.Ports.SerialPortNames` property gets a collection of the names of the serial ports on the computer.
> [!NOTE]
> The port names returned by `My.Computer.Ports.SerialPortNames` may be incorrect when run on Windows 98. To prevent application errors, use exception handling, such as the `Try...Catch...Finally` statement or the `Using` statement, when using the port names to open ports.
The following table lists an example of a task involving the `My.Computer.Ports.SerialPortNames` property.
|To|See|
|-|-|
|Show available serial ports|[How to: Show Available Serial Ports](~/docs/visual-basic/developing-apps/programming/computer-resources/how-to-show-available-serial-ports.md)|
## Availability by Project Type
|Project type|Available|
|-|-|
|Windows Application|**Yes**|
|Class Library|**Yes**|
|Console Application|**Yes**|
|Windows Control Library|**Yes**|
|Web Control Library|No|
|Windows Service|**Yes**|
|Web Site|No|
## Examples
This example loops over all the strings that the `My.Computer.Ports.SerialPortNames` property returns. These strings are the names of the available serial ports on the computer.
Typically, a user selects which serial port the application should use from the list of available ports. In this example, the serial port names are stored in a <xref:System.Windows.Forms.ListBox> control. For more information, see [ListBox Control](~/docs/framework/winforms/controls/listbox-control-windows-forms.md).
[!code-vb[VbVbalrMyComputer#45](~/samples/snippets/visualbasic/VS_Snippets_VBCSharp/VbVbalrMyComputer/VB/Class2.vb#45)]
This example requires:
- A reference to the <xref:System?displayProperty=nameWithType> namespace.
- That your form have a <xref:System.Windows.Forms.ListBox> control named `ListBox1`.
For more information, see [How to: Show Available Serial Ports](~/docs/visual-basic/developing-apps/programming/computer-resources/how-to-show-available-serial-ports.md).
]]></format>
</remarks>
<altCompliant cref="None." />
<altmember cref="Overload:Microsoft.VisualBasic.Devices.Ports.OpenSerialPort" />
<altmember cref="T:System.Collections.ObjectModel.ReadOnlyCollection`1" />
</Docs>
</Member>
</Members>
</Type>