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