-
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
Conversation
|
Closing and reopening - failed build |
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.
I've left a number of comments suggesting additional changes, @JRAlexander.
|
|
||
| This article includes several examples that illustrate uses of the `If`...`Then`...`Else`statement: | ||
|
|
||
| * [Multiple-line syntax example](#multi-line) |
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.
Multiple-line --> Multiline
|
|
||
| ## Parts | ||
| `condition` | ||
| Required. Expression. Must evaluate to `True` or `False`, or to a data type that is implicitly convertible to `Boolean`. |
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`"
| Optional. One or more statements that are executed if no previous `condition` or `elseifcondition` expression evaluates to `True`. | ||
|
|
||
| `End If` | ||
| Terminates the `If`...`Then`...`Else` block. |
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.
Terminates the multiline version of...
|
|
||
|
|
||
|
|
||
| ## Remarks |
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.
lines 89 and 99 should be level-3 heads, not level-2
line 90: space between True and elseifcondition
line 97: several possible values --> more than three possible values
line 100 doesn't actually say what single-line syntax is: a single condition with code to execute if it's true
|
|
||
| In the single-line syntax, you can have multiple statements executed as the result of an `If`...`Then` decision. All statements must be on the same line and be separated by colons. | ||
|
|
||
| ## Example |
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.
The Example header can't be deleted.
| ## Example | ||
| <a name="multi-line"></a> | ||
|
|
||
| The following example illustrates the use of the multiple-line syntax of the `If`...`Then`...`Else` statement. |
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.
multiple-line --> multiline
|
|
||
| The following example illustrates the use of the multiple-line syntax of the `If`...`Then`...`Else` statement. | ||
|
|
||
| [!code-vb[VbVbalrStatements#101](../../../visual-basic/language-reference/error-messages/codesnippet/VisualBasic/if-then-else-statement_1.vb)] |
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.
It might be good here to make this executable -- so wrap it in:
Module Multiline
Public Sub Main()
Console.WriteLine(message)
End Sub
End Module
Also, instead of "There are " & count & " items." --> $"There are {count} items." (to use an interpolated string)
And also show output
|
|
||
| The following example contains nested `If`...`Then`...`Else` statements. | ||
|
|
||
| [!code-vb[VbVbalrStatements#102](../../../visual-basic/language-reference/error-messages/codesnippet/VisualBasic/if-then-else-statement_2.vb)] |
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.
It would also be good to wrap this in a Module...End Module statement, include a Main method so it's executable, and add output
The comments also aren't fully accurate. It doesn't test for 2 to 4 PM or noon to 1 PM, but from 2 to 3:59 and 12 to 12:59.
| <a name="single-line"></a> | ||
| The following example illustrates the use of the single-line syntax. | ||
|
|
||
| [!code-vb[VbVbalrStatements#103](../../../visual-basic/language-reference/error-messages/codesnippet/VisualBasic/if-then-else-statement_3.vb)] |
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.
Here again, this could be a complete code example that's executable. You can use highlighting here (as well as in the other two examples) to focus on the If statements.
|
@rpetrusha I believe I've addressed all your comments. I'm having a bit of an issue with highlighting. |
|
The problem with highlighting, @JRAlexander, is that the syntax is incorrect. Instead of |
|
Got it! Thanks, @rpetrusha! Now I believe I've addressed everything! |
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.
This looks good, @JRAlexander. The one thing that's missing is output from the example, which can be commented-out at the end of the example. It's important to include them here, since the REPL isn't supported yet. Once you add them, you can merge.
|
|
||
| ## Quick links to example code | ||
|
|
||
| This article includes several examples that illustrate uses of the `If`...`Then`...`Else`statement: |
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.
missing space at the end before statement
| If the expression is a [Nullable](../../../visual-basic/programming-guide/language-features/data-types/nullable-value-types.md) `Boolean` variable that evaluates to [Nothing](../../../visual-basic/language-reference/nothing.md), the condition is treated as if the expression is `False` and the `Else` block is executed. | ||
|
|
||
| `Then` | ||
| Required in the single-line syntax; optional in the multiple-line syntax. |
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.
didn't you change this to multiline?
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.
Missed that.
|
|
||
| ## Example | ||
|
|
||
| ## Multiline Syntax Example |
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.
given that you're completely revisiting the topic, I'd also fix the headings to be sentence case
|
Thank you, @rpetrusha and @mairaw, for your thoughtful comments! |
If...Then...Else Statement (Visual Basic) API topic has repeated requests for updates. We'll update it, point to the relevant examples, and improve the experience.
Fixes #3505
URL for internal review