Repository navigation
Expand file tree
/
Copy pathInteraction.xml
More file actions
1376 lines (1136 loc) · 95.4 KB
/
Copy pathInteraction.xml
File metadata and controls
1376 lines (1136 loc) · 95.4 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
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<Type Name="Interaction" FullName="Microsoft.VisualBasic.Interaction">
<TypeSignature Language="C#" Value="public sealed class Interaction" />
<TypeSignature Language="ILAsm" Value=".class public auto ansi sealed beforefieldinit Interaction extends System.Object" />
<TypeSignature Language="DocId" Value="T:Microsoft.VisualBasic.Interaction" />
<TypeSignature Language="VB.NET" Value="Public Module Interaction" />
<TypeSignature Language="C++ CLI" Value="public ref class Interaction sealed" />
<AssemblyInfo>
<AssemblyName>Microsoft.VisualBasic</AssemblyName>
<AssemblyVersion>10.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Base>
<BaseTypeName>System.Object</BaseTypeName>
</Base>
<Interfaces />
<Attributes>
<Attribute>
<AttributeName>Microsoft.VisualBasic.CompilerServices.StandardModule</AttributeName>
</Attribute>
</Attributes>
<Docs>
<summary>The <see langword="Interaction" /> module contains procedures used to interact with objects, applications, and systems.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
This module supports the Visual Basic language keywords and run-time library members that run other programs, call a method or property, sound a beep from the computer, provide a command-line string, manipulate COM objects, and control dialog boxes.
## Examples
The following example uses the `Shell` function to run an application specified by the user. Specifying <xref:Microsoft.VisualBasic.AppWinStyle.NormalFocus?displayProperty=nameWithType> as the second argument opens the application in normal size and gives it the focus.
```vb
Dim procID As Integer
' Run calculator.
procID = Shell("C:\Windows\system32\calc.exe", AppWinStyle.NormalFocus)
' The preceding path is for Windows XP.
' The Windows 2000 path is C:\WINNT\system32\calc.exe.
```
]]></format>
</remarks>
</Docs>
<Members>
<MemberGroup MemberName="AppActivate">
<AssemblyInfo>
<AssemblyName>Microsoft.VisualBasic</AssemblyName>
<AssemblyVersion>10.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Docs>
<summary>Activates an application that is already running.</summary>
</Docs>
</MemberGroup>
<Member MemberName="AppActivate">
<MemberSignature Language="C#" Value="public static void AppActivate (int ProcessId);" />
<MemberSignature Language="ILAsm" Value=".method public static void AppActivate(int32 ProcessId) cil managed" />
<MemberSignature Language="DocId" Value="M:Microsoft.VisualBasic.Interaction.AppActivate(System.Int32)" />
<MemberSignature Language="VB.NET" Value="Public Sub AppActivate (ProcessId As Integer)" />
<MemberSignature Language="C++ CLI" Value="public:
 static void AppActivate(int ProcessId);" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>Microsoft.VisualBasic</AssemblyName>
<AssemblyVersion>10.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute>
<AttributeName>System.Security.SecuritySafeCritical</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.Void</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="ProcessId" Type="System.Int32" />
</Parameters>
<Docs>
<param name="ProcessId">
<see langword="Integer" /> specifying the Win32 process ID number assigned to this process. You can use the ID returned by the <see cref="M:Microsoft.VisualBasic.Interaction.Shell(System.String,Microsoft.VisualBasic.AppWinStyle,System.Boolean,System.Int32)" />, provided it is not zero.</param>
<summary>Activates an application that is already running.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
You use `AppActivate` to bring an application's active window into focus. You might not have a handle or a reference to the active window, or even know which window is active at a given moment. In such a case, you cannot use the <xref:System.Windows.Forms.Control.Focus%2A> method.
The `AppActivate` function changes the focus to the named application or window but does not affect whether it is maximized or minimized. Focus moves away from the activated application window when the user takes some action to change the focus or close the window. You can use the `Shell` function to start an application and set the window style.
If you use the `Title` parameter, `AppActivate` uses a case-insensitive comparison but otherwise requires an exact match with the contents of the title bar. It first looks through the top-level windows and then through the child windows. If it cannot find a match, it throws an <xref:System.ArgumentException>.
You can use `AppActivate` only with processes that own windows. Most console applications do not own windows, which means that they do not appear in the list of processes that `AppActivate` searches. When running from a console application, the system creates a separate process to run the application and returns the output to the console process. Consequently, when you request the current process ID, you get the process ID of this separate process, rather than the console application's process ID.
At run time, the `AppActivate` function activates any running application with a title that matches `Title` or with a process ID that matches `ProcessId`. If there is no exact match, it activates any application whose title string ends with `Title`. If there is more than one application named `Title`, the `AppActivate` function arbitrarily chooses one to activate.
> [!NOTE]
> The `AppActivate` function requires `UIPermission` at the <xref:System.Security.Permissions.UIPermissionWindow.SafeTopLevelWindows> level, which may affect its execution in partial-trust situations. For more information, see <xref:System.Security.Permissions.UIPermission> .
## Examples
This example illustrates various uses of the `AppActivate` function to activate an application window. If a Notepad process is not running, the example throws an <xref:System.ArgumentException>. The `Shell` procedure assumes the applications are in the paths specified.
[!code-vb[VbVbalrCatRef#11](~/samples/snippets/visualbasic/VS_Snippets_VBCSharp/VbVbalrCatRef/VB/Class1.vb#11)]
]]></format>
</remarks>
<altmember cref="M:Microsoft.VisualBasic.Interaction.Shell(System.String,Microsoft.VisualBasic.AppWinStyle,System.Boolean,System.Int32)" />
<altmember cref="M:System.Windows.Forms.Control.Focus" />
<altmember cref="T:System.ArgumentException" />
</Docs>
</Member>
<Member MemberName="AppActivate">
<MemberSignature Language="C#" Value="public static void AppActivate (string Title);" />
<MemberSignature Language="ILAsm" Value=".method public static void AppActivate(string Title) cil managed" />
<MemberSignature Language="DocId" Value="M:Microsoft.VisualBasic.Interaction.AppActivate(System.String)" />
<MemberSignature Language="VB.NET" Value="Public Sub AppActivate (Title As String)" />
<MemberSignature Language="C++ CLI" Value="public:
 static void AppActivate(System::String ^ Title);" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>Microsoft.VisualBasic</AssemblyName>
<AssemblyVersion>10.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute>
<AttributeName>System.Security.SecuritySafeCritical</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.Void</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="Title" Type="System.String" />
</Parameters>
<Docs>
<param name="Title">
<see langword="String" /> expression specifying the title in the title bar of the application you want to activate. You can use the title assigned to the application when it was launched.</param>
<summary>Activates an application that is already running.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
You use `AppActivate` to bring an application's active window into focus. You might not have a handle or a reference to the active window, or even know which window is active at a given moment. In such a case, you cannot use the <xref:System.Windows.Forms.Control.Focus%2A> method.
The `AppActivate` function changes the focus to the named application or window but does not affect whether it is maximized or minimized. Focus moves away from the activated application window when the user takes some action to change the focus or close the window. You can use the `Shell` function to start an application and set the window style.
If you use the `Title` parameter, `AppActivate` uses a case-insensitive comparison but otherwise requires an exact match with the contents of the title bar. It first looks through the top-level windows and then through the child windows. If it cannot find a match, it throws an <xref:System.ArgumentException>.
You can use `AppActivate` only with processes that own windows. Most console applications do not own windows, which means that they do not appear in the list of processes that `AppActivate` searches. When running from a console application, the system creates a separate process to run the application and returns the output to the console process. Consequently, when you request the current process ID, you get the process ID of this separate process, rather than the console application's process ID.
At run time, the `AppActivate` function activates any running application with a title that matches `Title` or with a process ID that matches `ProcessId`. If there is no exact match, it activates any application whose title string ends with `Title`. If there is more than one application named `Title`, the `AppActivate` function arbitrarily chooses one to activate.
> [!NOTE]
> The `AppActivate` function requires `UIPermission` at the <xref:System.Security.Permissions.UIPermissionWindow.SafeTopLevelWindows> level, which may affect its execution in partial-trust situations. For more information, see <xref:System.Security.Permissions.UIPermission> .
## Examples
This example illustrates various uses of the `AppActivate` function to activate an application window. If a Notepad process is not running, the example throws an <xref:System.ArgumentException>. The `Shell` procedure assumes the applications are in the paths specified.
[!code-vb[VbVbalrCatRef#11](~/samples/snippets/visualbasic/VS_Snippets_VBCSharp/VbVbalrCatRef/VB/Class1.vb#11)]
]]></format>
</remarks>
<altmember cref="M:Microsoft.VisualBasic.Interaction.Shell(System.String,Microsoft.VisualBasic.AppWinStyle,System.Boolean,System.Int32)" />
<altmember cref="M:System.Windows.Forms.Control.Focus" />
<altmember cref="T:System.ArgumentException" />
</Docs>
</Member>
<Member MemberName="Beep">
<MemberSignature Language="C#" Value="public static void Beep ();" />
<MemberSignature Language="ILAsm" Value=".method public static void Beep() cil managed" />
<MemberSignature Language="DocId" Value="M:Microsoft.VisualBasic.Interaction.Beep" />
<MemberSignature Language="VB.NET" Value="Public Sub Beep ()" />
<MemberSignature Language="C++ CLI" Value="public:
 static void Beep();" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>Microsoft.VisualBasic</AssemblyName>
<AssemblyVersion>10.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute>
<AttributeName>System.Security.SecuritySafeCritical</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.Void</ReturnType>
</ReturnValue>
<Parameters />
<Docs>
<summary>Sounds a tone through the computer's speaker.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The pitch and duration of the beep depend on your hardware and system software and therefore vary among computers.
> [!NOTE]
> The `Beep` function requires `UIPermission` at the <xref:System.Security.Permissions.UIPermissionWindow.SafeTopLevelWindows> level, which may affect its execution in partial-trust situations. For more information, see <xref:System.Security.Permissions.UIPermission>.
## Examples
This example uses the `Beep` function to sound a tone through the computer's speaker.
[!code-vb[VbVbalrCatRef#59](~/samples/snippets/visualbasic/VS_Snippets_VBCSharp/VbVbalrCatRef/VB/Class1.vb#59)]
]]></format>
</remarks>
</Docs>
</Member>
<Member MemberName="CallByName">
<MemberSignature Language="C#" Value="public static object CallByName (object ObjectRef, string ProcName, Microsoft.VisualBasic.CallType UseCallType, params object[] Args);" />
<MemberSignature Language="ILAsm" Value=".method public static object CallByName(object ObjectRef, string ProcName, valuetype Microsoft.VisualBasic.CallType UseCallType, object[] Args) cil managed" />
<MemberSignature Language="DocId" Value="M:Microsoft.VisualBasic.Interaction.CallByName(System.Object,System.String,Microsoft.VisualBasic.CallType,System.Object[])" />
<MemberSignature Language="VB.NET" Value="Public Function CallByName (ObjectRef As Object, ProcName As String, UseCallType As CallType, ParamArray Args As Object()) As Object" />
<MemberSignature Language="C++ CLI" Value="public:
 static System::Object ^ CallByName(System::Object ^ ObjectRef, System::String ^ ProcName, Microsoft::VisualBasic::CallType UseCallType, ... cli::array <System::Object ^> ^ Args);" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>Microsoft.VisualBasic</AssemblyName>
<AssemblyVersion>10.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Object</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="ObjectRef" Type="System.Object" />
<Parameter Name="ProcName" Type="System.String" />
<Parameter Name="UseCallType" Type="Microsoft.VisualBasic.CallType" />
<Parameter Name="Args" Type="System.Object[]">
<Attributes>
<Attribute>
<AttributeName>System.ParamArray</AttributeName>
</Attribute>
</Attributes>
</Parameter>
</Parameters>
<Docs>
<param name="ObjectRef">Required. <see langword="Object" />. A pointer to the object exposing the property or method.</param>
<param name="ProcName">Required. <see langword="String" />. A string expression containing the name of the property or method on the object.</param>
<param name="UseCallType">Required. An enumeration member of type <see cref="T:Microsoft.VisualBasic.CallType" /> representing the type of procedure being called. The value of <see langword="CallType" /> can be <see langword="Method" />, <see langword="Get" />, or <see langword="Set" />.</param>
<param name="Args">Optional. <see langword="ParamArray" />. A parameter array containing the arguments to be passed to the property or method being called.</param>
<summary>Executes a method on an object, or sets or returns a property on an object.</summary>
<returns>Executes a method on an object, or sets or returns a property on an object.</returns>
<remarks>
<format type="text/markdown"><]
[!code-vb[VbVbalrFunctions#20](~/samples/snippets/visualbasic/VS_Snippets_VBCSharp/VbVbalrFunctions/VB/Class1.vb#20)]
The next example uses the `CallByName` function to invoke the `Add` and `Item` methods of a collection object.
[!code-vb[VbVbalrFunctions#21](~/samples/snippets/visualbasic/VS_Snippets_VBCSharp/VbVbalrFunctions/VB/Class1.vb#21)]
]]></format>
</remarks>
<exception cref="T:System.ArgumentException">Invalid <paramref name="UseCallType" /> value; must be <see langword="Method" />, <see langword="Get" />, or <see langword="Set" />.</exception>
<altmember cref="T:Microsoft.VisualBasic.CallType" />
<altmember cref="T:System.ArgumentException" />
</Docs>
</Member>
<Member MemberName="Choose">
<MemberSignature Language="C#" Value="public static object Choose (double Index, params object[] Choice);" />
<MemberSignature Language="ILAsm" Value=".method public static object Choose(float64 Index, object[] Choice) cil managed" />
<MemberSignature Language="DocId" Value="M:Microsoft.VisualBasic.Interaction.Choose(System.Double,System.Object[])" />
<MemberSignature Language="VB.NET" Value="Public Function Choose (Index As Double, ParamArray Choice As Object()) As Object" />
<MemberSignature Language="C++ CLI" Value="public:
 static System::Object ^ Choose(double Index, ... cli::array <System::Object ^> ^ Choice);" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>Microsoft.VisualBasic</AssemblyName>
<AssemblyVersion>10.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Object</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="Index" Type="System.Double" />
<Parameter Name="Choice" Type="System.Object[]">
<Attributes>
<Attribute>
<AttributeName>System.ParamArray</AttributeName>
</Attribute>
</Attributes>
</Parameter>
</Parameters>
<Docs>
<param name="Index">Required. <see langword="Double" />. Numeric expression that results in a value between 1 and the number of elements passed in the <c>Choice</c> argument.</param>
<param name="Choice">Required. <see langword="Object" /> parameter array. You can supply either a single variable or an expression that evaluates to the <see langword="Object" /> data type, to a list of <see langword="Object" /> variables or expressions separated by commas, or to a single-dimensional array of <see langword="Object" /> elements.</param>
<summary>Selects and returns a value from a list of arguments.</summary>
<returns>Selects and returns a value from a list of arguments.</returns>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The `Choose` function returns a member of the list passed in `Choice()`, based on the value of `Index`. The first member of the list is selected when `Index` is 1. The last member of the list is selected when `Index` is `UBound`(`Choice()`). If `Index` is outside these limits, `Choose` returns `Nothing`.
If `Index` is not a whole number, it is rounded to the nearest whole number before being evaluated.
You can use `Choose` to look up a value in a list of possibilities.
> [!NOTE]
> The expressions in the argument list can include function calls. As part of preparing the argument list for the call to `Choose`, the Visual Basic compiler calls every function in every expression. This means that you cannot rely on a particular function not being called if a different expression is selected by `Index`.
## Examples
This example uses the `Choose` function to display a name in response to an index passed into the procedure in the `Ind` parameter.
[!code-vb[VbVbalrFunctions#22](~/samples/snippets/visualbasic/VS_Snippets_VBCSharp/VbVbalrFunctions/VB/Class1.vb#22)]
]]></format>
</remarks>
<altmember cref="M:Microsoft.VisualBasic.Interaction.IIf(System.Boolean,System.Object,System.Object)" />
<altmember cref="M:Microsoft.VisualBasic.Interaction.Switch(System.Object[])" />
</Docs>
</Member>
<Member MemberName="Command">
<MemberSignature Language="C#" Value="public static string Command ();" />
<MemberSignature Language="ILAsm" Value=".method public static string Command() cil managed" />
<MemberSignature Language="DocId" Value="M:Microsoft.VisualBasic.Interaction.Command" />
<MemberSignature Language="VB.NET" Value="Public Function Command () As String" />
<MemberSignature Language="C++ CLI" Value="public:
 static System::String ^ Command();" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>Microsoft.VisualBasic</AssemblyName>
<AssemblyVersion>10.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute>
<AttributeName>System.Security.SecuritySafeCritical</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.String</ReturnType>
</ReturnValue>
<Parameters />
<Docs>
<summary>Returns the argument portion of the command line used to start Visual Basic or an executable program developed with Visual Basic. The <see langword="My" /> feature provides greater productivity and performance than the <see langword="Command" /> function. For more information, see <see cref="P:Microsoft.VisualBasic.ApplicationServices.ConsoleApplicationBase.CommandLineArgs" />.</summary>
<returns>Returns the argument portion of the command line used to start Visual Basic or an executable program developed with Visual Basic.
The <see langword="My" /> feature provides greater productivity and performance than the <see langword="Command" /> function. For more information, see <see cref="P:Microsoft.VisualBasic.ApplicationServices.ConsoleApplicationBase.CommandLineArgs" />.</returns>
<remarks>
<format type="text/markdown"><]
]]></format>
</remarks>
<altmember cref="M:System.Environment.GetCommandLineArgs" />
<altmember cref="P:Microsoft.VisualBasic.ApplicationServices.ConsoleApplicationBase.CommandLineArgs" />
</Docs>
</Member>
<Member MemberName="CreateObject">
<MemberSignature Language="C#" Value="public static object CreateObject (string ProgId, string ServerName = "");" />
<MemberSignature Language="ILAsm" Value=".method public static object CreateObject(string ProgId, string ServerName) cil managed" />
<MemberSignature Language="DocId" Value="M:Microsoft.VisualBasic.Interaction.CreateObject(System.String,System.String)" />
<MemberSignature Language="VB.NET" Value="Public Function CreateObject (ProgId As String, Optional ServerName As String = "") As Object" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>Microsoft.VisualBasic</AssemblyName>
<AssemblyVersion>10.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute>
<AttributeName>System.Security.SecuritySafeCritical</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.Object</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="ProgId" Type="System.String" />
<Parameter Name="ServerName" Type="System.String" />
</Parameters>
<Docs>
<param name="ProgId">Required. <see langword="String" />. The program ID of the object to create.</param>
<param name="ServerName">Optional. <see langword="String" />. The name of the network server where the object will be created. If <c>ServerName</c> is an empty string (""), the local computer is used.</param>
<summary>Creates and returns a reference to a COM object. <see langword="CreateObject" /> cannot be used to create instances of classes in Visual Basic unless those classes are explicitly exposed as COM components.</summary>
<returns>Creates and returns a reference to a COM object. <see langword="CreateObject" /> cannot be used to create instances of classes in Visual Basic unless those classes are explicitly exposed as COM components.</returns>
<remarks>
<format type="text/markdown"><.
You should generally use strongly bound objects and primary interop assemblies whenever possible. The examples below use the `CreateObject` function with Microsoft Office objects for demonstration purposes only. However, these objects are easier to use and more reliable when used with the appropriate primary interop assembly.
## Creating an Object on a Remote Computer
You can create an object on a remote networked computer by passing the name of the computer to the `ServerName` argument of the `CreateObject` function. That name is the same as the Machine Name portion of a share name: for a share named "\\\MyServer\Public," `ServerName` is "MyServer."
> [!NOTE]
> Refer to COM documentation (see Microsoft Developer Network) for additional information on making an application accessible on a remote networked computer. You may need to add a registry key for your application.
The following code returns the version number of an instance of Excel running on a remote computer named `MyServer`:
```vb
Sub CreateRemoteExcelObj()
Dim xlApp As Object
' Replace string "\\MyServer" with name of the remote computer.
xlApp = CreateObject("Excel.Application", "\\MyServer")
MsgBox(xlApp.Version)
End Sub
```
If the remote server name is incorrect, or if it is unavailable, a run-time error occurs.
> [!NOTE]
> Use `CreateObject` when there is no current instance of the object. If an instance of the object is already running, a new instance is started, and an object of the specified type is created. To use the current instance, or to start the application and have it load a file, use the `GetObject` function. If an object has registered itself as a single-instance object, only one instance of the object is created, no matter how many times `CreateObject` is executed.
## Creating Framework Objects
You can use the `CreateObject` function only to create a COM object. While there is no exact equivalent mechanism for creating a .NET Framework object, the <xref:System.Activator> in the <xref:System> namespace contains methods to create local or remote objects. In particular, the <xref:System.Activator.CreateInstance%2A> method or the <xref:System.Activator.CreateInstanceFrom%2A> method might be useful.
> [!IMPORTANT]
> The `CreateObject` function requires unmanaged code permission, which might affect its execution in partial-trust situations. For more information, see <xref:System.Security.Permissions.SecurityPermission> and [Code Access Permissions](http://msdn.microsoft.com/library/e5ae402f-6dda-4732-bbe8-77296630f675).
## Examples
The following example uses the `CreateObject` function to create a Microsoft Excel worksheet and saves the worksheet to a file. To use this example, Excel must be installed on the computer where this program runs. Also, you must add a reference to the type library from the **COM** tab of the **Add Reference** dialog box on the **Project** menu. The name of the type library varies depending on the version of Excel installed on your computer. For example, the type library for Microsoft Excel 2002 is named **Microsoft Excel 10.0 Object Library**.
[!code-vb[VbVbalrExcelObject#1](~/samples/snippets/visualbasic/VS_Snippets_VBCSharp/VbVbalrExcelObject/VB/Class1.vb#1)]
]]></format>
</remarks>
<exception cref="T:System.Exception">Server is unavailable</exception>
<exception cref="T:System.IO.FileNotFoundException">No object of the specified type exists</exception>
<altmember cref="M:Microsoft.VisualBasic.Interaction.GetObject(System.String,System.String)" />
<altmember cref="T:System.Exception" />
<altmember cref="T:System.IO.FileNotFoundException" />
<altmember cref="T:System.Activator" />
<altmember cref="Overload:System.Activator.CreateInstance" />
<altmember cref="Overload:System.Activator.CreateInstanceFrom" />
</Docs>
</Member>
<Member MemberName="DeleteSetting">
<MemberSignature Language="C#" Value="public static void DeleteSetting (string AppName, string Section = null, string Key = null);" />
<MemberSignature Language="ILAsm" Value=".method public static void DeleteSetting(string AppName, string Section, string Key) cil managed" />
<MemberSignature Language="DocId" Value="M:Microsoft.VisualBasic.Interaction.DeleteSetting(System.String,System.String,System.String)" />
<MemberSignature Language="VB.NET" Value="Public Sub DeleteSetting (AppName As String, Optional Section As String = null, Optional Key As String = null)" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>Microsoft.VisualBasic</AssemblyName>
<AssemblyVersion>10.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Void</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="AppName" Type="System.String" />
<Parameter Name="Section" Type="System.String" />
<Parameter Name="Key" Type="System.String" />
</Parameters>
<Docs>
<param name="AppName">Required. <see langword="String" /> expression containing the name of the application or project to which the section or key setting applies.</param>
<param name="Section">Required. <see langword="String" /> expression containing the name of the section from which the key setting is being deleted. If only <c>AppName</c> and <c>Section</c> are provided, the specified section is deleted along with all related key settings.</param>
<param name="Key">Optional. <see langword="String" /> expression containing the name of the key setting being deleted.</param>
<summary>Deletes a section or key setting from an application's entry in the Windows registry. The <see langword="My" /> feature gives you greater productivity and performance in registry operations than the <see langword="DeleteSetting" /> function. For more information, see <see cref="P:Microsoft.VisualBasic.Devices.ServerComputer.Registry" /> .</summary>
<remarks>
<format type="text/markdown"><]
]]></format>
</remarks>
<exception cref="T:System.ArgumentException">User is not logged in.</exception>
<altmember cref="M:Microsoft.VisualBasic.Interaction.GetAllSettings(System.String,System.String)" />
<altmember cref="M:Microsoft.VisualBasic.Interaction.GetSetting(System.String,System.String,System.String,System.String)" />
<altmember cref="M:Microsoft.VisualBasic.Interaction.SaveSetting(System.String,System.String,System.String,System.String)" />
<altmember cref="T:System.ArgumentException" />
</Docs>
</Member>
<MemberGroup MemberName="Environ">
<AssemblyInfo>
<AssemblyName>Microsoft.VisualBasic</AssemblyName>
<AssemblyVersion>10.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Docs>
<summary>Returns the string associated with an operating-system environment variable.</summary>
</Docs>
</MemberGroup>
<Member MemberName="Environ">
<MemberSignature Language="C#" Value="public static string Environ (int Expression);" />
<MemberSignature Language="ILAsm" Value=".method public static string Environ(int32 Expression) cil managed" />
<MemberSignature Language="DocId" Value="M:Microsoft.VisualBasic.Interaction.Environ(System.Int32)" />
<MemberSignature Language="VB.NET" Value="Public Function Environ (Expression As Integer) As String" />
<MemberSignature Language="C++ CLI" Value="public:
 static System::String ^ Environ(int Expression);" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>Microsoft.VisualBasic</AssemblyName>
<AssemblyVersion>10.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute>
<AttributeName>System.Security.SecuritySafeCritical</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.String</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="Expression" Type="System.Int32" />
</Parameters>
<Docs>
<param name="Expression">Required. Expression that evaluates either a string containing the name of an environment variable, or an integer corresponding to the numeric order of an environment string in the environment-string table.</param>
<summary>Returns the string associated with an operating-system environment variable.</summary>
<returns>Returns the string associated with an operating-system environment variable.</returns>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
If `Expression` contains a string, the <xref:Microsoft.VisualBasic.Interaction.Environ%2A> function returns the text assigned to the specified environment string—that is, the text following the equal sign (=) in the environment-string table for that environment variable. If the string in `Expression` cannot be found in the environment-string table, a zero-length string ("") is returned.
If `Expression` contains an integer, the string occupying that numeric position in the environment-string table is returned. In this case, <xref:Microsoft.VisualBasic.Interaction.Environ%2A> returns all of the text, including the name of the environment variable. If there is no environment string in the specified position, <xref:Microsoft.VisualBasic.Interaction.Environ%2A> returns a zero-length string.
> [!IMPORTANT]
> The <xref:Microsoft.VisualBasic.Interaction.Environ%2A> function requires environment permission, which might affect its execution in partial-trust situations. For more information, see <xref:System.Security.Permissions.SecurityPermission> and [Code Access Permissions](http://msdn.microsoft.com/library/e5ae402f-6dda-4732-bbe8-77296630f675).
## Examples
This example uses the <xref:Microsoft.VisualBasic.Interaction.Environ%2A> function to supply the entry number and length of the `PATH` statement from the environment-string table.
[!code-vb[VbVbalrCatRef#28](~/samples/snippets/visualbasic/VS_Snippets_VBCSharp/VbVbalrCatRef/VB/Class1.vb#28)]
]]></format>
</remarks>
<exception cref="T:System.ArgumentException">
<paramref name="Expression" /> is missing.</exception>
<altmember cref="T:System.ArgumentException" />
</Docs>
</Member>
<Member MemberName="Environ">
<MemberSignature Language="C#" Value="public static string Environ (string Expression);" />
<MemberSignature Language="ILAsm" Value=".method public static string Environ(string Expression) cil managed" />
<MemberSignature Language="DocId" Value="M:Microsoft.VisualBasic.Interaction.Environ(System.String)" />
<MemberSignature Language="VB.NET" Value="Public Function Environ (Expression As String) As String" />
<MemberSignature Language="C++ CLI" Value="public:
 static System::String ^ Environ(System::String ^ Expression);" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>Microsoft.VisualBasic</AssemblyName>
<AssemblyVersion>10.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.String</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="Expression" Type="System.String" />
</Parameters>
<Docs>
<param name="Expression">Required. Expression that evaluates either a string containing the name of an environment variable, or an integer corresponding to the numeric order of an environment string in the environment-string table.</param>
<summary>Returns the string associated with an operating-system environment variable.</summary>
<returns>Returns the string associated with an operating-system environment variable.</returns>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
If `Expression` contains a string, the <xref:Microsoft.VisualBasic.Interaction.Environ%2A> function returns the text assigned to the specified environment string—that is, the text following the equal sign (=) in the environment-string table for that environment variable. If the string in `Expression` cannot be found in the environment-string table, a zero-length string ("") is returned.
If `Expression` contains an integer, the string occupying that numeric position in the environment-string table is returned. In this case, <xref:Microsoft.VisualBasic.Interaction.Environ%2A> returns all of the text, including the name of the environment variable. If there is no environment string in the specified position, <xref:Microsoft.VisualBasic.Interaction.Environ%2A> returns a zero-length string.
> [!IMPORTANT]
> The <xref:Microsoft.VisualBasic.Interaction.Environ%2A> function requires environment permission, which might affect its execution in partial-trust situations. For more information, see <xref:System.Security.Permissions.SecurityPermission> and [Code Access Permissions](http://msdn.microsoft.com/library/e5ae402f-6dda-4732-bbe8-77296630f675).
## Examples
This example uses the <xref:Microsoft.VisualBasic.Interaction.Environ%2A> function to supply the entry number and length of the `PATH` statement from the environment-string table.
[!code-vb[VbVbalrCatRef#28](~/samples/snippets/visualbasic/VS_Snippets_VBCSharp/VbVbalrCatRef/VB/Class1.vb#28)]
]]></format>
</remarks>
<exception cref="T:System.ArgumentException">
<paramref name="Expression" /> is missing.</exception>
<altmember cref="T:System.ArgumentException" />
</Docs>
</Member>
<Member MemberName="GetAllSettings">
<MemberSignature Language="C#" Value="public static string[,] GetAllSettings (string AppName, string Section);" />
<MemberSignature Language="ILAsm" Value=".method public static string[,] GetAllSettings(string AppName, string Section) cil managed" />
<MemberSignature Language="DocId" Value="M:Microsoft.VisualBasic.Interaction.GetAllSettings(System.String,System.String)" />
<MemberSignature Language="VB.NET" Value="Public Function GetAllSettings (AppName As String, Section As String) As String(,)" />
<MemberSignature Language="C++ CLI" Value="public:
 static cli::array <System::String ^, 2> ^ GetAllSettings(System::String ^ AppName, System::String ^ Section);" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>Microsoft.VisualBasic</AssemblyName>
<AssemblyVersion>10.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.String[,]</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="AppName" Type="System.String" />
<Parameter Name="Section" Type="System.String" />
</Parameters>
<Docs>
<param name="AppName">Required. <see langword="String" /> expression containing the name of the application or project whose key settings are requested.</param>
<param name="Section">Required. <see langword="String" /> expression containing the name of the section whose key settings are requested. <see langword="GetAllSettings" /> returns an object that contains a two-dimensional array of strings. The strings contain all the key settings in the specified section, plus their corresponding values.</param>
<summary>Returns a list of key settings and their respective values (originally created with <see langword="SaveSetting" />) from an application's entry in the Windows registry. Using the <see langword="My" /> feature gives you greater productivity and performance in registry operations than <see langword="GetAllSettings" />. For more information, see <see cref="P:Microsoft.VisualBasic.Devices.ServerComputer.Registry" />.</summary>
<returns>Returns a list of key settings and their respective values (originally created with <see langword="SaveSetting" />) from an application's entry in the Windows registry.
Using the <see langword="My" /> feature gives you greater productivity and performance in registry operations than <see langword="GetAllSettings" />. For more information, see <see cref="P:Microsoft.VisualBasic.Devices.ServerComputer.Registry" />.</returns>
<remarks>
<format type="text/markdown"><]
]]></format>
</remarks>
<exception cref="T:System.ArgumentException">User is not logged in.</exception>
<altmember cref="M:Microsoft.VisualBasic.Interaction.DeleteSetting(System.String,System.String,System.String)" />
<altmember cref="M:Microsoft.VisualBasic.Interaction.GetSetting(System.String,System.String,System.String,System.String)" />
<altmember cref="M:Microsoft.VisualBasic.Interaction.SaveSetting(System.String,System.String,System.String,System.String)" />
<altmember cref="T:System.ArgumentException" />
</Docs>
</Member>
<Member MemberName="GetObject">
<MemberSignature Language="C#" Value="public static object GetObject (string PathName = null, string Class = null);" />
<MemberSignature Language="ILAsm" Value=".method public static object GetObject(string PathName, string Class) cil managed" />
<MemberSignature Language="DocId" Value="M:Microsoft.VisualBasic.Interaction.GetObject(System.String,System.String)" />
<MemberSignature Language="VB.NET" Value="Public Function GetObject (Optional PathName As String = null, Optional Class As String = null) As Object" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>Microsoft.VisualBasic</AssemblyName>
<AssemblyVersion>10.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute>
<AttributeName>System.Security.SecuritySafeCritical</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.Object</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="PathName" Type="System.String" />
<Parameter Name="Class" Type="System.String" />
</Parameters>
<Docs>
<param name="PathName">Optional. <see langword="String" />. The full path and name of the file containing the object to retrieve. If <c>PathName</c> is omitted, <c>Class</c> is required.</param>
<param name="Class">Required if <c>PathName</c> is not supplied. <see langword="String" />. A string representing the class of the object. The <c>Class</c> argument has the following syntax and parts:
<c>appname</c><c>.</c><c>objecttype</c>
[1|1] Parameter
[1|2] Description
[2|1] <c>appname</c>
[2|2] Required. <see langword="String" />. The name of the application providing the object.
[3|1] <c>objecttype</c>
[3|2] Required. <see langword="String" />. The type or class of object to create.</param>
<summary>Returns a reference to an object provided by a COM component.</summary>
<returns>Returns a reference to an object provided by a COM component.</returns>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
Use the `GetObject` function to load an instance of a COM component from a file. The following example illustrates this.
```vb
Dim CADObject As Object
CADObject = GetObject("C:\CAD\schema.cad")
```
When this code runs, the application associated with the specified `PathName` is started and the object in the specified file is activated.
## Default Cases
If `PathName` is a zero-length string (`""`), `GetObject` returns a new object instance of the specified class type. If the `PathName` argument is omitted, `GetObject` returns a currently active object of the class type specified in `Class`. If no object of the specified type exists, an error occurs.
## Accessing a Subobject
Some applications allow you to activate a subobject associated with a file. To do this, add an exclamation point (`!`) to the end of the file name and follow it with a string that identifies the part of the file you want to activate. For information on how to create this string, see the documentation for the application that created the object.
For example, in a drawing application you might have multiple layers to a drawing stored in a file. You could use the following code to activate a layer within a drawing called `schema.cad`.
```vb
layerObject = GetObject("C:\CAD\schema.cad!Layer3")
```
## Specifying a Class
If you do not specify the object's `Class`, Automation determines the application to start and the object to activate, based on the file name you provide. Some files, however, can support more than one class of object. For example, a drawing might support three different types of objects: an `Application` object, a `Drawing` object, and a `Toolbar` object, all of which are part of the same file. To specify which object in a file you want to activate, use the optional `Class` argument. The following example illustrates this.
```vb
Dim drawObj As Object
drawObj = GetObject("C:\Drawings\sample.drw", "Figment.Drawing")
```
In the preceding example, `Figment` is the name of a drawing application and `Drawing` is one of the object types it supports.
## Using the Object
Once an object is activated, you refer to it in code using the object variable you declared. In the preceding example, you access properties and methods of the new object using the object variable `drawObj`. The following example illustrates this.
```vb
drawObj.Line(9, 90)
drawObj.InsertText(9, 100, "Hello, world.")
drawObj.SaveAs("C:\Drawings\sample.drw")
```
> [!NOTE]
> Use the `GetObject` function when there is a current instance of the object or if you want to create the object with a file loaded. If there is no current instance, and you do not want the object started with a file loaded, use the <xref:Microsoft.VisualBasic.Interaction.CreateObject%2A> function.
>
> If an object has registered itself as an ActiveX single-instance object, only one instance of the object is created, no matter how many times `CreateObject` is called. With a single-instance object, `GetObject` always returns the same instance when called with the zero-length string (`""`) syntax, and it causes an error if the `PathName` argument is omitted. You cannot use `GetObject` to obtain a reference to a class created with Visual Basic.
> [!IMPORTANT]
> The `GetObject` function requires unmanaged code permission, which might affect its execution in partial-trust situations. For more information, see <xref:System.Security.Permissions.SecurityPermission> and [Code Access Permissions](http://msdn.microsoft.com/library/e5ae402f-6dda-4732-bbe8-77296630f675).
## Examples
The following example uses the `GetObject` function to obtain a reference to a specific Microsoft Excel worksheet (`excelObj`). It uses the worksheet's `Application` property to make Excel visible, to close it, and to perform other actions. Using two API calls, the `detectExcel` procedure looks for Excel, and if it is running, enters it in the Running Object table. The first call to `GetObject` causes an error if Excel is not already running, which in this example causes the `excelWasNotRunning` flag to be set to `True`. The second call to `GetObject` specifies a file to open. If Excel is not already running, the second call starts it and returns a reference to the worksheet represented by the specified file, `test.xls`. The file must exist in the specified location; otherwise, Visual Basic throws a <xref:System.IO.FileNotFoundException>. Next, the example code makes both Excel and the window containing the specified worksheet visible.
This example requires `Option Strict Off` because it uses late binding, where objects are assigned to variables of type `Object`. You can specify `Option Strict On` and declare objects of specific object types if you add a reference to the Excel type library from the **COM** tab of the **Add Reference** dialog box of the **Project** menu in Visual Studio.
[!code-vb[VbVbalrExcelObject#2](~/samples/snippets/visualbasic/VS_Snippets_VBCSharp/VbVbalrExcelObject/VB/Class1.vb#2)]
[!code-vb[VbVbalrExcelObject#4](~/samples/snippets/visualbasic/VS_Snippets_VBCSharp/VbVbalrExcelObject/VB/Class1.vb#4)]
[!code-vb[VbVbalrExcelObject#5](~/samples/snippets/visualbasic/VS_Snippets_VBCSharp/VbVbalrExcelObject/VB/Class1.vb#5)]
When you call the `getExcel` function, a check is made to see if Excel is already running. If it is not, then an instance is created.
> [!IMPORTANT]
> For simplicity, the preceding example assumes that any window called `XLMAIN` belongs to an instance of Microsoft Excel. If another object, possibly launched by illicit tampering, created a window with that name, it would receive all the messages you intended for Excel. In an application to be used for production, you should include some more rigorous testing to verify that `XLMAIN` really belongs to Excel.
]]></format>
</remarks>
<exception cref="T:System.Exception">No object of the specified class type exists.</exception>
<exception cref="T:System.IO.FileNotFoundException">No object with the specified path and file name exists.</exception>
<altmember cref="M:Microsoft.VisualBasic.Interaction.CreateObject(System.String,System.String)" />
<altmember cref="T:System.Exception" />
<altmember cref="T:System.IO.FileNotFoundException" />
</Docs>
</Member>
<Member MemberName="GetSetting">
<MemberSignature Language="C#" Value="public static string GetSetting (string AppName, string Section, string Key, string Default = "");" />
<MemberSignature Language="ILAsm" Value=".method public static string GetSetting(string AppName, string Section, string Key, string Default) cil managed" />
<MemberSignature Language="DocId" Value="M:Microsoft.VisualBasic.Interaction.GetSetting(System.String,System.String,System.String,System.String)" />
<MemberSignature Language="VB.NET" Value="Public Function GetSetting (AppName As String, Section As String, Key As String, Optional Default As String = "") As String" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>Microsoft.VisualBasic</AssemblyName>
<AssemblyVersion>10.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.String</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="AppName" Type="System.String" />
<Parameter Name="Section" Type="System.String" />
<Parameter Name="Key" Type="System.String" />
<Parameter Name="Default" Type="System.String" />
</Parameters>
<Docs>
<param name="AppName">Required. <see langword="String" /> expression containing the name of the application or project whose key setting is requested.</param>
<param name="Section">Required. <see langword="String" /> expression containing the name of the section in which the key setting is found.</param>
<param name="Key">Required. <see langword="String" /> expression containing the name of the key setting to return.</param>
<param name="Default">Optional. Expression containing the value to return if no value is set in the <c>Key</c> setting. If omitted, <c>Default</c> is assumed to be a zero-length string ("").</param>
<summary>Returns a key setting value from an application's entry in the Windows registry. The <see langword="My" /> feature gives you greater productivity and performance in registry operations than <see langword="GetAllSettings" />. For more information, see <see cref="P:Microsoft.VisualBasic.Devices.ServerComputer.Registry" />.</summary>
<returns>Returns a key setting value from an application's entry in the Windows registry.
The <see langword="My" /> feature gives you greater productivity and performance in registry operations than <see langword="GetAllSettings" />.</returns>
<remarks>
<format type="text/markdown"><]
]]></format>
</remarks>
<exception cref="T:System.ArgumentException">One or more arguments are not <see langword="String" /> expressions, or user is not logged in.</exception>
<altmember cref="M:Microsoft.VisualBasic.Interaction.DeleteSetting(System.String,System.String,System.String)" />
<altmember cref="M:Microsoft.VisualBasic.Interaction.GetAllSettings(System.String,System.String)" />
<altmember cref="M:Microsoft.VisualBasic.Interaction.SaveSetting(System.String,System.String,System.String,System.String)" />
<altmember cref="T:System.ArgumentException" />
<altmember cref="T:System.Security.Permissions.RegistryPermission" />
</Docs>
</Member>
<Member MemberName="IIf">
<MemberSignature Language="C#" Value="public static object IIf (bool Expression, object TruePart, object FalsePart);" />
<MemberSignature Language="ILAsm" Value=".method public static object IIf(bool Expression, object TruePart, object FalsePart) cil managed" />
<MemberSignature Language="DocId" Value="M:Microsoft.VisualBasic.Interaction.IIf(System.Boolean,System.Object,System.Object)" />
<MemberSignature Language="VB.NET" Value="Public Function IIf (Expression As Boolean, TruePart As Object, FalsePart As Object) As Object" />
<MemberSignature Language="C++ CLI" Value="public:
 static System::Object ^ IIf(bool Expression, System::Object ^ TruePart, System::Object ^ FalsePart);" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>Microsoft.VisualBasic</AssemblyName>
<AssemblyVersion>10.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Object</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="Expression" Type="System.Boolean" />
<Parameter Name="TruePart" Type="System.Object" />
<Parameter Name="FalsePart" Type="System.Object" />
</Parameters>
<Docs>
<param name="Expression">Required. <see langword="Boolean" />. The expression you want to evaluate.</param>
<param name="TruePart">Required. <see langword="Object" />. Returned if <c>Expression</c> evaluates to <see langword="True" />.</param>
<param name="FalsePart">Required. <see langword="Object" />. Returned if <c>Expression</c> evaluates to <see langword="False" />.</param>
<summary>Returns one of two objects, depending on the evaluation of an expression.</summary>
<returns>Returns one of two objects, depending on the evaluation of an expression.</returns>
<remarks>
<format type="text/markdown">< in Visual C++.
## Examples
This example uses the `IIf` function to evaluate the `testMe` parameter of the `checkIt` procedure and returns the word "Large" if the amount is greater than 1000; otherwise, it returns the word "Small".
[!code-vb[VbVbalrFunctions#33](~/samples/snippets/visualbasic/VS_Snippets_VBCSharp/VbVbalrFunctions/VB/Class1.vb#33)]
Note that if `Option Strict` is `On`, you must use the `CStr` keyword to explicitly convert the return from `Object` to `String`.
]]></format>
</remarks>
<altmember cref="M:Microsoft.VisualBasic.Interaction.Choose(System.Double,System.Object[])" />
<altmember cref="M:Microsoft.VisualBasic.Interaction.Switch(System.Object[])" />
</Docs>
</Member>
<Member MemberName="InputBox">
<MemberSignature Language="C#" Value="public static string InputBox (string Prompt, string Title = "", string DefaultResponse = "", int XPos = -1, int YPos = -1);" />
<MemberSignature Language="ILAsm" Value=".method public static string InputBox(string Prompt, string Title, string DefaultResponse, int32 XPos, int32 YPos) cil managed" />
<MemberSignature Language="DocId" Value="M:Microsoft.VisualBasic.Interaction.InputBox(System.String,System.String,System.String,System.Int32,System.Int32)" />
<MemberSignature Language="VB.NET" Value="Public Function InputBox (Prompt As String, Optional Title As String = "", Optional DefaultResponse As String = "", Optional XPos As Integer = -1, Optional YPos As Integer = -1) As String" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>Microsoft.VisualBasic</AssemblyName>
<AssemblyVersion>10.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.String</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="Prompt" Type="System.String" />
<Parameter Name="Title" Type="System.String" />
<Parameter Name="DefaultResponse" Type="System.String" />
<Parameter Name="XPos" Type="System.Int32" />
<Parameter Name="YPos" Type="System.Int32" />
</Parameters>
<Docs>
<param name="Prompt">Required <see langword="String" /> expression displayed as the message in the dialog box. The maximum length of <c>Prompt</c> is approximately 1024 characters, depending on the width of the characters used. If <c>Prompt</c> consists of more than one line, you can separate the lines using a carriage return character (<see langword="Chr(" />13<see langword=")" />), a line feed character (<see langword="Chr(" />10<see langword=")" />), or a carriage return/line feed combination (<see langword="Chr(" />13<see langword=")" /> & <see langword="Chr(" />10<see langword=")" />) between each line.</param>
<param name="Title">Optional. <see langword="String" /> expression displayed in the title bar of the dialog box. If you omit <c>Title</c>, the application name is placed in the title bar.</param>
<param name="DefaultResponse">Optional. <see langword="String" /> expression displayed in the text box as the default response if no other input is provided. If you omit <c>DefaultResponse</c>, the displayed text box is empty.</param>
<param name="XPos">Optional. Numeric expression that specifies, in twips, the distance of the left edge of the dialog box from the left edge of the screen. If you omit <c>XPos</c>, the dialog box is centered horizontally.</param>
<param name="YPos">Optional. Numeric expression that specifies, in twips, the distance of the upper edge of the dialog box from the top of the screen. If you omit <c>YPos</c>, the dialog box is positioned vertically approximately one-third of the way down the screen.</param>
<summary>Displays a prompt in a dialog box, waits for the user to input text or click a button, and then returns a string containing the contents of the text box.</summary>
<returns>Displays a prompt in a dialog box, waits for the user to input text or click a button, and then returns a string containing the contents of the text box.</returns>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
If the user clicks **Cancel**, a zero-length string is returned.
To specify more than the first argument, you must use the `InputBox` function in an expression. If you omit any positional arguments, you must retain the corresponding comma delimiter.
> [!NOTE]
> The `InputBox` function requires `UIPermission` at the <xref:System.Security.Permissions.UIPermissionWindow.SafeTopLevelWindows> level, which may affect its execution in partial-trust situations. For more information, see and <xref:System.Security.Permissions.UIPermission> .
## Examples
This example shows various ways to use the `InputBox` function to prompt the user to enter a value. If the x and y positions are omitted, the dialog box is automatically centered for the respective axes. The variable `MyValue` contains the value entered by the user if the user clicks OK or presses the ENTER key.
[!code-vb[VbVbalrCatRef#67](~/samples/snippets/visualbasic/VS_Snippets_VBCSharp/VbVbalrCatRef/VB/Class1.vb#67)]
]]></format>
</remarks>
<altmember cref="M:Microsoft.VisualBasic.Interaction.MsgBox(System.Object,Microsoft.VisualBasic.MsgBoxStyle,System.Object)" />
<altmember cref="M:Microsoft.VisualBasic.Strings.Chr(System.Int32)" />
<altmember cref="M:Microsoft.VisualBasic.Strings.ChrW(System.Int32)" />
</Docs>
</Member>
<Member MemberName="MsgBox">
<MemberSignature Language="C#" Value="public static Microsoft.VisualBasic.MsgBoxResult MsgBox (object Prompt, Microsoft.VisualBasic.MsgBoxStyle Buttons = Microsoft.VisualBasic.MsgBoxStyle.ApplicationModal, object Title = null);" />
<MemberSignature Language="ILAsm" Value=".method public static valuetype Microsoft.VisualBasic.MsgBoxResult MsgBox(object Prompt, valuetype Microsoft.VisualBasic.MsgBoxStyle Buttons, object Title) cil managed" />
<MemberSignature Language="DocId" Value="M:Microsoft.VisualBasic.Interaction.MsgBox(System.Object,Microsoft.VisualBasic.MsgBoxStyle,System.Object)" />
<MemberSignature Language="VB.NET" Value="Public Function MsgBox (Prompt As Object, Optional Buttons As MsgBoxStyle = Microsoft.VisualBasic.MsgBoxStyle.ApplicationModal, Optional Title As Object = null) As MsgBoxResult" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>Microsoft.VisualBasic</AssemblyName>
<AssemblyVersion>10.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>Microsoft.VisualBasic.MsgBoxResult</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="Prompt" Type="System.Object" />
<Parameter Name="Buttons" Type="Microsoft.VisualBasic.MsgBoxStyle" />
<Parameter Name="Title" Type="System.Object" />
</Parameters>
<Docs>
<param name="Prompt">Required. <see langword="String" /> expression displayed as the message in the dialog box. The maximum length of <c>Prompt</c> is approximately 1024 characters, depending on the width of the characters used. If <c>Prompt</c> consists of more than one line, you can separate the lines using a carriage return character (<see langword="Chr(" />13<see langword=")" />), a line feed character (<see langword="Chr(" />10<see langword=")" />), or a carriage return/linefeed character combination (<see langword="Chr(" />13<see langword=")" /> & <see langword="Chr(" />10<see langword=")" />) between each line.</param>
<param name="Buttons">Optional. Numeric expression that is the sum of values specifying the number and type of buttons to display, the icon style to use, the identity of the default button, and the modality of the message box. If you omit <c>Buttons</c>, the default value is zero.</param>
<param name="Title">Optional. <see langword="String" /> expression displayed in the title bar of the dialog box. If you omit <c>Title</c>, the application name is placed in the title bar.</param>
<summary>Displays a message in a dialog box, waits for the user to click a button, and then returns an integer indicating which button the user clicked.</summary>
<returns>
<list type="table">
<item>
<term> Constant
</term>
<description> Value
</description>
</item>
<item>
<term>
<see langword="OK" />
</term>
<description> 1
</description>
</item>
<item>
<term>
<see langword="Cancel" />
</term>
<description> 2
</description>
</item>
<item>
<term>
<see langword="Abort" />
</term>