Skip to content

Commit e781fc9

Browse files
nschonnimairaw
authored andcommitted
fix: MD009/no-trailing-spaces (#15264)
- Trailing spaces - Remove orphan ordered lists
1 parent 74921b5 commit e781fc9

24 files changed

+1318
-1273
lines changed
Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,30 @@
11
---
22
title: "Optional parameters must specify a default value"
33
ms.date: 07/20/2015
4-
f1_keywords:
4+
f1_keywords:
55
- "vbc30812"
66
- "bc30812"
7-
helpviewer_keywords:
7+
helpviewer_keywords:
88
- "BC30812"
99
ms.assetid: 5091a250-be66-413b-98a3-2a9974c4d600
1010
---
1111
# Optional parameters must specify a default value
12-
Optional parameters must provide default values that can be used if no parameter is supplied by a calling procedure.
13-
14-
**Error ID:** BC30812
15-
16-
## To correct this error
17-
18-
- Specify default values for optional parameters; for example:
19-
20-
```vb
21-
Sub Proc1(ByVal X As Integer,
22-
Optional ByVal Y As String = "Default Value")
23-
MsgBox("Default argument is: " & Y)
24-
End Sub
25-
```
26-
12+
13+
Optional parameters must provide default values that can be used if no parameter is supplied by a calling procedure.
14+
15+
**Error ID:** BC30812
16+
17+
## To correct this error
18+
19+
Specify default values for optional parameters; for example:
20+
21+
```vb
22+
Sub Proc1(ByVal X As Integer,
23+
Optional ByVal Y As String = "Default Value")
24+
MsgBox("Default argument is: " & Y)
25+
End Sub
26+
```
27+
2728
## See also
2829

2930
- [Optional](../../../visual-basic/language-reference/modifiers/optional.md)

docs/visual-basic/language-reference/modifiers/withevents.md

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,38 @@
11
---
22
title: "WithEvents (Visual Basic)"
33
ms.date: 07/20/2015
4-
f1_keywords:
4+
f1_keywords:
55
- "vb.WithEvents"
66
- "WithEvents"
7-
helpviewer_keywords:
7+
helpviewer_keywords:
88
- "WithEvents keyword [Visual Basic]"
99
ms.assetid: 19d461f5-d72f-4de9-8c1d-0a6650316990
1010
---
1111
# WithEvents (Visual Basic)
12-
Specifies that one or more declared member variables refer to an instance of a class that can raise events.
13-
14-
## Remarks
15-
When a variable is defined using `WithEvents`, you can declaratively specify that a method handles the variable's events using the `Handles` keyword.
16-
17-
You can use `WithEvents` only at class or module level. This means the declaration context for a `WithEvents` variable must be a class or module and cannot be a source file, namespace, structure, or procedure.
18-
19-
You cannot use `WithEvents` on a structure member.
20-
21-
You can declare only individual variables—not arrays—with `WithEvents`.
22-
23-
## Rules
24-
25-
- **Element Types.** You must declare `WithEvents` variables to be object variables so that they can accept class instances. However, you cannot declare them as `Object`. You must declare them as the specific class that can raise the events.
26-
27-
The `WithEvents` modifier can be used in this context: [Dim Statement](../../../visual-basic/language-reference/statements/dim-statement.md)
28-
12+
Specifies that one or more declared member variables refer to an instance of a class that can raise events.
13+
14+
## Remarks
15+
16+
When a variable is defined using `WithEvents`, you can declaratively specify that a method handles the variable's events using the `Handles` keyword.
17+
18+
You can use `WithEvents` only at class or module level. This means the declaration context for a `WithEvents` variable must be a class or module and cannot be a source file, namespace, structure, or procedure.
19+
20+
You cannot use `WithEvents` on a structure member.
21+
22+
You can declare only individual variables—not arrays—with `WithEvents`.
23+
24+
## Rules
25+
26+
**Element Types.** You must declare `WithEvents` variables to be object variables so that they can accept class instances. However, you cannot declare them as `Object`. You must declare them as the specific class that can raise the events.
27+
28+
The `WithEvents` modifier can be used in this context: [Dim Statement](../../../visual-basic/language-reference/statements/dim-statement.md)
29+
2930
## Example
3031

31-
```VB
32+
```vb
3233
Dim WithEvents app As Application
3334
```
34-
35+
3536
## See also
3637

3738
- [Handles](../../../visual-basic/language-reference/statements/handles-clause.md)

docs/visual-basic/language-reference/statements/const-statement.md

Lines changed: 92 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -1,98 +1,103 @@
11
---
22
title: "Const Statement (Visual Basic)"
33
ms.date: 05/12/2018
4-
f1_keywords:
4+
f1_keywords:
55
- "vb.Const"
6-
helpviewer_keywords:
6+
helpviewer_keywords:
77
- "Const statement [Visual Basic]"
88
ms.assetid: 495b318d-b7c5-4198-94f8-0790a541b07a
99
---
1010
# Const Statement (Visual Basic)
11-
Declares and defines one or more constants.
12-
13-
## Syntax
14-
15-
```vb
16-
[ <attributelist> ] [ accessmodifier ] [ Shadows ]
17-
Const constantlist
18-
```
19-
20-
## Parts
21-
`attributelist`
22-
Optional. List of attributes that apply to all the constants declared in this statement. See [Attribute List](../../../visual-basic/language-reference/statements/attribute-list.md) in angle brackets ("`<`" and "`>`").
23-
24-
`accessmodifier`
25-
Optional. Use this to specify what code can access these constants. Can be [Public](../../../visual-basic/language-reference/modifiers/public.md), [Protected](../../../visual-basic/language-reference/modifiers/protected.md), [Friend](../../../visual-basic/language-reference/modifiers/friend.md), [Protected Friend](../modifiers/protected-friend.md), [Private](../../../visual-basic/language-reference/modifiers/private.md), or [Private Protected](../../language-reference/modifiers/private-protected.md).
26-
27-
`Shadows`
28-
Optional. Use this to redeclare and hide a programming element in a base class. See [Shadows](../../../visual-basic/language-reference/modifiers/shadows.md).
29-
30-
`constantlist`
31-
Required. List of constants being declared in this statement.
32-
33-
`constant` `[ ,` `constant` `... ]`
34-
35-
Each `constant` has the following syntax and parts:
36-
37-
`constantname` `[ As` `datatype` `] =` `initializer`
38-
39-
|Part|Description|
40-
|----------|-----------------|
41-
|`constantname`|Required. Name of the constant. See [Declared Element Names](../../../visual-basic/programming-guide/language-features/declared-elements/declared-element-names.md).|
42-
|`datatype`|Required if `Option Strict` is `On`. Data type of the constant.|
43-
|`initializer`|Required. Expression that is evaluated at compile time and assigned to the constant.|
44-
45-
## Remarks
46-
If you have a value that never changes in your application, you can define a named constant and use it in place of a literal value. A name is easier to remember than a value. You can define the constant just once and use it in many places in your code. If in a later version you need to redefine the value, the `Const` statement is the only place you need to make a change.
47-
48-
You can use `Const` only at module or procedure level. This means the *declaration context* for a variable must be a class, structure, module, procedure, or block, and cannot be a source file, namespace, or interface. For more information, see [Declaration Contexts and Default Access Levels](../../../visual-basic/language-reference/statements/declaration-contexts-and-default-access-levels.md).
49-
50-
Local constants (inside a procedure) default to public access, and you cannot use any access modifiers on them. Class and module member constants (outside any procedure) default to private access, and structure member constants default to public access. You can adjust their access levels with the access modifiers.
51-
52-
## Rules
53-
54-
- **Declaration Context.** A constant declared at module level, outside any procedure, is a *member constant*; it is a member of the class, structure, or module that declares it.
55-
56-
A constant declared at procedure level is a *local constant*; it is local to the procedure or block that declares it.
57-
58-
- **Attributes.** You can apply attributes only to member constants, not to local constants. An attribute contributes information to the assembly's metadata, which is not meaningful for temporary storage such as local constants.
59-
60-
- **Modifiers.** By default, all constants are `Shared`, `Static`, and `ReadOnly`. You cannot use any of these keywords when declaring a constant.
61-
62-
At procedure level, you cannot use `Shadows` or any access modifiers to declare local constants.
63-
64-
- **Multiple Constants.** You can declare several constants in the same declaration statement, specifying the `constantname` part for each one. Multiple constants are separated by commas.
65-
66-
## Data Type Rules
67-
68-
- **Data Types.** The `Const` statement can declare the data type of a variable. You can specify any data type or the name of an enumeration.
69-
70-
- **Default Type.** If you do not specify `datatype`, the constant takes the data type of `initializer`. If you specify both `datatype` and `initializer`, the data type of `initializer` must be convertible to `datatype`. If neither `datatype` nor `initializer` is present, the data type defaults to `Object`.
71-
72-
- **Different Types.** You can specify different data types for different constants by using a separate `As` clause for each variable you declare. However, you cannot declare several constants to be of the same type by using a common `As` clause.
73-
74-
- **Initialization.** You must initialize the value of every constant in `constantlist`. You use `initializer` to supply an expression to be assigned to the constant. The expression can be any combination of literals, other constants that are already defined, and enumeration members that are already defined. You can use arithmetic and logical operators to combine such elements.
75-
76-
You cannot use variables or functions in `initializer`. However, you can use conversion keywords such as `CByte` and `CShort`. You can also use `AscW` if you call it with a constant `String` or `Char` argument, since that can be evaluated at compile time.
77-
78-
## Behavior
79-
80-
- **Scope.** Local constants are accessible only from within their procedure or block. Member constants are accessible from anywhere within their class, structure, or module.
81-
82-
- **Qualification.** Code outside a class, structure, or module must qualify a member constant's name with the name of that class, structure, or module. Code outside a procedure or block cannot refer to any local constants within that procedure or block.
83-
84-
## Example
85-
The following example uses the `Const` statement to declare constants for use in place of literal values.
86-
87-
[!code-vb[VbVbalrStatements#13](~/samples/snippets/visualbasic/VS_Snippets_VBCSharp/VbVbalrStatements/VB/Class1.vb#13)]
88-
89-
## Example
90-
If you define a constant with data type `Object`, the Visual Basic compiler gives it the type of `initializer`, instead of `Object`. In the following example, the constant `naturalLogBase` has the run-time type `Decimal`.
91-
92-
[!code-vb[VbVbalrStatements#87](~/samples/snippets/visualbasic/VS_Snippets_VBCSharp/VbVbalrStatements/VB/Class1.vb#87)]
93-
94-
The preceding example uses the <xref:System.Type.ToString%2A> method on the <xref:System.Type> object returned by the [GetType Operator](../../../visual-basic/language-reference/operators/gettype-operator.md), because <xref:System.Type> cannot be converted to `String` using `CStr`.
95-
11+
12+
Declares and defines one or more constants.
13+
14+
## Syntax
15+
16+
```vb
17+
[ <attributelist> ] [ accessmodifier ] [ Shadows ]
18+
Const constantlist
19+
```
20+
21+
## Parts
22+
23+
`attributelist`
24+
Optional. List of attributes that apply to all the constants declared in this statement. See [Attribute List](../../../visual-basic/language-reference/statements/attribute-list.md) in angle brackets ("`<`" and "`>`").
25+
26+
`accessmodifier`
27+
Optional. Use this to specify what code can access these constants. Can be [Public](../../../visual-basic/language-reference/modifiers/public.md), [Protected](../../../visual-basic/language-reference/modifiers/protected.md), [Friend](../../../visual-basic/language-reference/modifiers/friend.md), [Protected Friend](../modifiers/protected-friend.md), [Private](../../../visual-basic/language-reference/modifiers/private.md), or [Private Protected](../../language-reference/modifiers/private-protected.md).
28+
29+
`Shadows`
30+
Optional. Use this to redeclare and hide a programming element in a base class. See [Shadows](../../../visual-basic/language-reference/modifiers/shadows.md).
31+
32+
`constantlist`
33+
Required. List of constants being declared in this statement.
34+
35+
`constant` `[ ,` `constant` `... ]`
36+
37+
Each `constant` has the following syntax and parts:
38+
39+
`constantname` `[ As` `datatype` `] =` `initializer`
40+
41+
|Part|Description|
42+
|----------|-----------------|
43+
|`constantname`|Required. Name of the constant. See [Declared Element Names](../../../visual-basic/programming-guide/language-features/declared-elements/declared-element-names.md).|
44+
|`datatype`|Required if `Option Strict` is `On`. Data type of the constant.|
45+
|`initializer`|Required. Expression that is evaluated at compile time and assigned to the constant.|
46+
47+
## Remarks
48+
49+
If you have a value that never changes in your application, you can define a named constant and use it in place of a literal value. A name is easier to remember than a value. You can define the constant just once and use it in many places in your code. If in a later version you need to redefine the value, the `Const` statement is the only place you need to make a change.
50+
51+
You can use `Const` only at module or procedure level. This means the *declaration context* for a variable must be a class, structure, module, procedure, or block, and cannot be a source file, namespace, or interface. For more information, see [Declaration Contexts and Default Access Levels](../../../visual-basic/language-reference/statements/declaration-contexts-and-default-access-levels.md).
52+
53+
Local constants (inside a procedure) default to public access, and you cannot use any access modifiers on them. Class and module member constants (outside any procedure) default to private access, and structure member constants default to public access. You can adjust their access levels with the access modifiers.
54+
55+
## Rules
56+
57+
- **Declaration Context.** A constant declared at module level, outside any procedure, is a *member constant*; it is a member of the class, structure, or module that declares it.
58+
59+
A constant declared at procedure level is a *local constant*; it is local to the procedure or block that declares it.
60+
61+
- **Attributes.** You can apply attributes only to member constants, not to local constants. An attribute contributes information to the assembly's metadata, which is not meaningful for temporary storage such as local constants.
62+
63+
- **Modifiers.** By default, all constants are `Shared`, `Static`, and `ReadOnly`. You cannot use any of these keywords when declaring a constant.
64+
65+
At procedure level, you cannot use `Shadows` or any access modifiers to declare local constants.
66+
67+
- **Multiple Constants.** You can declare several constants in the same declaration statement, specifying the `constantname` part for each one. Multiple constants are separated by commas.
68+
69+
## Data Type Rules
70+
71+
- **Data Types.** The `Const` statement can declare the data type of a variable. You can specify any data type or the name of an enumeration.
72+
73+
- **Default Type.** If you do not specify `datatype`, the constant takes the data type of `initializer`. If you specify both `datatype` and `initializer`, the data type of `initializer` must be convertible to `datatype`. If neither `datatype` nor `initializer` is present, the data type defaults to `Object`.
74+
75+
- **Different Types.** You can specify different data types for different constants by using a separate `As` clause for each variable you declare. However, you cannot declare several constants to be of the same type by using a common `As` clause.
76+
77+
- **Initialization.** You must initialize the value of every constant in `constantlist`. You use `initializer` to supply an expression to be assigned to the constant. The expression can be any combination of literals, other constants that are already defined, and enumeration members that are already defined. You can use arithmetic and logical operators to combine such elements.
78+
79+
You cannot use variables or functions in `initializer`. However, you can use conversion keywords such as `CByte` and `CShort`. You can also use `AscW` if you call it with a constant `String` or `Char` argument, since that can be evaluated at compile time.
80+
81+
## Behavior
82+
83+
- **Scope.** Local constants are accessible only from within their procedure or block. Member constants are accessible from anywhere within their class, structure, or module.
84+
85+
- **Qualification.** Code outside a class, structure, or module must qualify a member constant's name with the name of that class, structure, or module. Code outside a procedure or block cannot refer to any local constants within that procedure or block.
86+
87+
## Example
88+
89+
The following example uses the `Const` statement to declare constants for use in place of literal values.
90+
91+
[!code-vb[VbVbalrStatements#13](~/samples/snippets/visualbasic/VS_Snippets_VBCSharp/VbVbalrStatements/VB/Class1.vb#13)]
92+
93+
## Example
94+
95+
If you define a constant with data type `Object`, the Visual Basic compiler gives it the type of `initializer`, instead of `Object`. In the following example, the constant `naturalLogBase` has the run-time type `Decimal`.
96+
97+
[!code-vb[VbVbalrStatements#87](~/samples/snippets/visualbasic/VS_Snippets_VBCSharp/VbVbalrStatements/VB/Class1.vb#87)]
98+
99+
The preceding example uses the <xref:System.Type.ToString%2A> method on the <xref:System.Type> object returned by the [GetType Operator](../../../visual-basic/language-reference/operators/gettype-operator.md), because <xref:System.Type> cannot be converted to `String` using `CStr`.
100+
96101
## See also
97102

98103
- <xref:Microsoft.VisualBasic.Strings.Asc%2A>

0 commit comments

Comments
 (0)