Skip to content

Commit

Permalink
Fixed bug 36231. (dotnet#44556)
Browse files Browse the repository at this point in the history
Co-authored-by: Adit Sheth <adsheth@microsoft.com>
  • Loading branch information
shethaadit and Adit Sheth authored Jan 28, 2025
1 parent 76212ab commit dfa0dfb
Showing 1 changed file with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,24 @@ You begin a structure declaration with the [Structure Statement](../../../langua
salary *= raise
End Sub
Public Event salaryReviewTime()

' Method to raise the event
Public Sub TriggerSalaryReview()
RaiseEvent salaryReviewTime()
End Sub
End Structure
```

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.

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:

```vb
Public Sub TriggerSalaryReview()
RaiseEvent salaryReviewTime()
End Sub
```

This allows you to control how and when the event is raised while keeping the event inaccessible directly from outside the structure.

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).

## See also
Expand Down

0 comments on commit dfa0dfb

Please sign in to comment.