Bram Moolenaar | f1dcd14 | 2022-12-31 15:30:45 +0000 | [diff] [blame^] | 1 | ' vim: filetype=vb shiftwidth=4 expandtab |
| 2 | ' |
| 3 | ' START_INDENT |
| 4 | Public Type GEmployeeRecord ' Create user-defined type. |
| 5 | ID As Integer ' Define elements of data type. |
| 6 | Name As String * 20 |
| 7 | Address As String * 30 |
| 8 | Phone As Long |
| 9 | HireDate As Date |
| 10 | End Type |
| 11 | |
| 12 | Public Enum InterfaceColors |
| 13 | icMistyRose = &HE1E4FF& |
| 14 | icSlateGray = &H908070& |
| 15 | icDodgerBlue = &HFF901E& |
| 16 | icDeepSkyBlue = &HFFBF00& |
| 17 | icSpringGreen = &H7FFF00& |
| 18 | icForestGreen = &H228B22& |
| 19 | icGoldenrod = &H20A5DA& |
| 20 | icFirebrick = &H2222B2& |
| 21 | End Enum |
| 22 | |
| 23 | Enum SecurityLevel |
| 24 | IllegalEntry = -1 |
| 25 | SecurityLevel1 = 0 |
| 26 | SecurityLevel2 = 1 |
| 27 | End Enum |
| 28 | |
| 29 | Public Function TestConditional (number As Integer, ext As String) As Boolean |
| 30 | Dim inRange As Boolean |
| 31 | |
| 32 | Select Case number |
| 33 | Case <= 0 |
| 34 | inRange = False |
| 35 | Case > 10 |
| 36 | inRange = False |
| 37 | Case Else |
| 38 | inRange = True |
| 39 | End Select |
| 40 | |
| 41 | ' This is a special case identified in the indent script. |
| 42 | Select Case number |
| 43 | End Select |
| 44 | |
| 45 | If ext = ".xlm" Then |
| 46 | If inRange Then |
| 47 | TestConditional = True |
| 48 | Else |
| 49 | TestConditional = False |
| 50 | End If |
| 51 | ElseIf ext = ".xlsx" Then |
| 52 | If inRange Then |
| 53 | TestConditional = False |
| 54 | Else |
| 55 | TestConditional = True |
| 56 | End If |
| 57 | Else |
| 58 | TestConditional = False |
| 59 | End If |
| 60 | End Function |
| 61 | |
| 62 | Private Sub TestIterators (lLimit As Integer, uLimit As Integer) |
| 63 | Dim a() As Variant |
| 64 | Dim elmt As Variant |
| 65 | Dim found As Boolean |
| 66 | Dim indx As Integer |
| 67 | Const specialValue As Integer = 5 |
| 68 | |
| 69 | If uLimit < lLimit Then |
| 70 | Exit Sub |
| 71 | End If |
| 72 | |
| 73 | ReDim a(lLimit To uLimit) |
| 74 | For indx=lLimit To Ulimit |
| 75 | a(indx) = 2 * indx |
| 76 | Next indx |
| 77 | |
| 78 | found = False |
| 79 | For Each elmt in a |
| 80 | If elmt = specialValue Then |
| 81 | found = True |
| 82 | End If |
| 83 | Next elmt |
| 84 | |
| 85 | If found then |
| 86 | indx = uLimit |
| 87 | Do While indx >= lLimit |
| 88 | indx = indx - 1 |
| 89 | Loop |
| 90 | End If |
| 91 | |
| 92 | End Sub |
| 93 | |
| 94 | Public Sub TestMultiline (cellAddr As String, rowNbr As Long) |
| 95 | Dim rng As Range |
| 96 | |
| 97 | Set rng = Range(cellAddr) |
| 98 | With rng |
| 99 | .Cells(1,1).Value = _ |
| 100 | "Line 1 of multiline string; " & _ |
| 101 | "Line 2 of multiline string; " & _ |
| 102 | "Line 3 of multiline string" |
| 103 | End With |
| 104 | |
| 105 | ' The following lines have whitespace after the underscore character |
| 106 | ' and therefore do not form a valid multiline statement. The indent |
| 107 | ' script correctly treats them as four single line statements contrary |
| 108 | ' to the author's obvious indent. |
| 109 | rng..Cells(1,1).Value = _ |
| 110 | "Line 1 of multiline string; " & _ |
| 111 | "Line 2 of multiline string; " & _ |
| 112 | "Line 3 of multiline string" |
| 113 | |
| 114 | End Sub |
| 115 | |
| 116 | Private Sub TestStmtLabel() |
| 117 | GoTo stmtLabel |
| 118 | |
| 119 | ' Statement labels are never indented |
| 120 | stmtLabel: |
| 121 | |
| 122 | End Sub |
| 123 | |
| 124 | Sub TestTypeKeyword() |
| 125 | Type EmployeeRecord ' Create user-defined type. |
| 126 | ID As Integer ' Define elements of data type. |
| 127 | Name As String * 20 |
| 128 | Address As String * 30 |
| 129 | Phone As Long |
| 130 | HireDate As Date |
| 131 | End Type |
| 132 | Dim varType As EmployeeRecord |
| 133 | End Sub |
| 134 | ' END_INDENT |