-
Notifications
You must be signed in to change notification settings - Fork 6.1k
Update If Then Else (Visual Basic) to improve CSAT #4942
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
1f7264b
Added Quick links to example code section
c1f30fa
Revised based on review feedback
4f87452
Updating code samples
4a754f2
Revising links
5405038
Updating Code sample links based on feedback
e950be8
revising code sample links
2e6f79b
Updating highlighting
fe2d3d3
Updated code comments, changed header case
0cfe042
Added Output at end of each sample, updated highlighting
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
19 changes: 17 additions & 2 deletions
19
...sic/language-reference/error-messages/codesnippet/VisualBasic/if-then-else-statement_1.vb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,25 @@ | ||
| Dim count As Integer = 0 | ||
| Module Multiline | ||
| Public Sub Main() | ||
| 'Create a Random object to seed our starting value | ||
| Dim randomizer As New Random() | ||
| 'set our variable | ||
| Dim count As Integer = randomizer.Next(0, 5) | ||
|
|
||
| Dim message As String | ||
|
|
||
| 'If count is zero, output will be no items | ||
| If count = 0 Then | ||
| message = "There are no items." | ||
| 'If count is 1, output will be "There is 1 item.". | ||
| ElseIf count = 1 Then | ||
| message = "There is 1 item." | ||
| 'If count is greater than 1, output will be "There are {count} items.", where {count} is replaced by the value of count. | ||
| Else | ||
| message = "There are " & count & " items." | ||
| message = $"There are {count} items." | ||
| End If | ||
|
|
||
| Console.WriteLine(message) | ||
| End Sub | ||
| End Module | ||
| 'This example displays output like the following: | ||
| ' There are 4 items. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 31 additions & 1 deletion
32
...sic/language-reference/error-messages/codesnippet/VisualBasic/if-then-else-statement_3.vb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,33 @@ | ||
| Module SingleLine | ||
| Public Sub Main() | ||
|
|
||
| 'Create a Random object to seed our starting values | ||
| Dim randomizer As New Random() | ||
|
|
||
| Dim A As Integer = randomizer.Next(10, 20) | ||
| Dim B As Integer = randomizer.Next(0, 20) | ||
| Dim C As Integer = randomizer.Next(0, 5) | ||
|
|
||
| 'Let's display the initial values for comparison | ||
| Console.WriteLine($"A value before If: {A}") | ||
| Console.WriteLine($"B value before If: {B}") | ||
| Console.WriteLine($"C value before If: {C}") | ||
|
|
||
| ' If A > 10, execute the three colon-separated statements in the order | ||
| ' that they appear | ||
| If A > 10 Then A = A + 1 : B = B + A : C = C + B | ||
| If A > 10 Then A = A + 1 : B = B + A : C = C + B | ||
|
|
||
| 'If the condition is true, the values will be different | ||
| Console.WriteLine($"A value after If: {A}") | ||
| Console.WriteLine($"B value after If: {B}") | ||
| Console.WriteLine($"C value after If: {C}") | ||
|
|
||
| End Sub | ||
| End Module | ||
| 'This example displays output like the following: | ||
| 'A value before If: 11 | ||
| 'B value before If: 6 | ||
| 'C value before If: 3 | ||
| 'A value after If: 12 | ||
| 'B value after If: 18 | ||
| 'C value after If: 21 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On line 65, there should be a space between Nullable and Boolean
if the expression is not True can be easily misread; much better to say "if the expression is `False`
no comma before "the `Else`"