You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/if.md
+13-8Lines changed: 13 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,13 +3,14 @@
3
3
**IF** is a very powerful control flow sentence that allows you to _make decisions_ under specified conditions.
4
4
5
5
## Syntax
6
-
```
7
-
IF expression [THEN] sentences [: END IF]
8
6
7
+
```basic
8
+
IF expression [THEN] sentences [: END IF]
9
9
```
10
+
10
11
or
11
12
12
-
```
13
+
```vbnet
13
14
IFexpression[THEN]
14
15
sentences
15
16
[ELSEIFexpression[THEN]sentences]
@@ -19,15 +20,17 @@ or
19
20
ENDIF
20
21
21
22
```
23
+
22
24
### Examples
23
-
```
25
+
26
+
```basic
24
27
IF a < 5 THEN PRINT "A is less than five" ELSE PRINT "A is greater than five"
25
28
```
26
29
27
30
28
31
Sentences might be in multiple lines:
29
32
30
-
```
33
+
```vbnet
31
34
Ifa<5Then
32
35
Print"A is less than five"
33
36
a=a+5
@@ -37,8 +40,10 @@ End If
37
40
```
38
41
39
42
40
-
Since **IF** is a _sentence_, it can be nested; however, remember that _every_**IF**_must be closed with_**END IF** when the line is split after **THEN** (mutiline **IF**):
41
-
```
43
+
Since **IF** is a _sentence_, it can be nested; however, remember that _every_**IF**_must be closed with_
44
+
`END IF` when the line is split after **THEN** (mutiline **IF**):
45
+
46
+
```vbnet
42
47
Ifa<5Then
43
48
Print"A is less than five"
44
49
Ifa>2Then
@@ -57,7 +62,7 @@ End If
57
62
In the example above, you see that nesting an **IF** inside another one could be somewhat verbose and error prone. It's better to use
58
63
the **ELSEIF** construct. So the previous example could be rewritten as:
0 commit comments