Skip to content

Commit dfa0dfb

Browse files
shethaaditAdit Sheth
andauthored
Fixed bug 36231. (#44556)
Co-authored-by: Adit Sheth <[email protected]>
1 parent 76212ab commit dfa0dfb

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

docs/visual-basic/programming-guide/language-features/data-types/how-to-declare-a-structure.md

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,24 @@ You begin a structure declaration with the [Structure Statement](../../../langua
4444
salary *= raise
4545
End Sub
4646
Public Event salaryReviewTime()
47+
48+
' Method to raise the event
49+
Public Sub TriggerSalaryReview()
50+
RaiseEvent salaryReviewTime()
51+
End Sub
4752
End Structure
4853
```
4954

50-
The `salary` field in the preceding example is `Private`, which means it is inaccessible outside the structure, even from the containing class. However, the `giveRaise` procedure is `Public`, so it can be called from outside the structure. Similarly, you can raise the `salaryReviewTime` event from outside the structure.
51-
55+
The `salary` field in the preceding example is `Private`, which means it is inaccessible outside the structure, even from the containing class. However, the `giveRaise` procedure is `Public`, so it can be called from outside the structure. Similarly, you can raise the `salaryReviewTime` event indirectly by calling a method within the structure that raises it. For example:
56+
57+
```vb
58+
Public Sub TriggerSalaryReview()
59+
RaiseEvent salaryReviewTime()
60+
End Sub
61+
```
62+
63+
This allows you to control how and when the event is raised while keeping the event inaccessible directly from outside the structure.
64+
5265
In addition to variables, `Sub` procedures, and events, you can also define constants, `Function` procedures, and properties in a structure. You can designate at most one property as the *default property*, provided it takes at least one argument. You can handle an event with a [Shared](../../../language-reference/modifiers/shared.md)`Sub` procedure. For more information, see [How to: Declare and Call a Default Property in Visual Basic](../procedures/how-to-declare-and-call-a-default-property.md).
5366

5467
## See also

0 commit comments

Comments
 (0)