Mercurial > vim
annotate runtime/indent/testdir/vb.ok @ 35280:ff2301a5e798 default tip
Added tag v9.1.0446 for changeset 95bb5918b0cf560504b765ded29c176ea11dd716
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sun, 26 May 2024 18:45:03 +0200 |
parents | f8e7e00787b5 |
children |
rev | line source |
---|---|
31579 | 1 ' vim: filetype=vb shiftwidth=4 expandtab |
2 ' | |
3 ' START_INDENT | |
35225
f8e7e00787b5
runtime(vb): update vb indent plugin as vim9script
Christian Brabandt <cb@256bit.org>
parents:
31579
diff
changeset
|
4 #Const Debug = False |
f8e7e00787b5
runtime(vb): update vb indent plugin as vim9script
Christian Brabandt <cb@256bit.org>
parents:
31579
diff
changeset
|
5 |
f8e7e00787b5
runtime(vb): update vb indent plugin as vim9script
Christian Brabandt <cb@256bit.org>
parents:
31579
diff
changeset
|
6 #If Win64 Then |
f8e7e00787b5
runtime(vb): update vb indent plugin as vim9script
Christian Brabandt <cb@256bit.org>
parents:
31579
diff
changeset
|
7 ' Win64=true, Win32=true, Win16=false |
f8e7e00787b5
runtime(vb): update vb indent plugin as vim9script
Christian Brabandt <cb@256bit.org>
parents:
31579
diff
changeset
|
8 #ElseIf Win32 Then |
f8e7e00787b5
runtime(vb): update vb indent plugin as vim9script
Christian Brabandt <cb@256bit.org>
parents:
31579
diff
changeset
|
9 ' Win32=true, Win16=false |
f8e7e00787b5
runtime(vb): update vb indent plugin as vim9script
Christian Brabandt <cb@256bit.org>
parents:
31579
diff
changeset
|
10 #Else |
f8e7e00787b5
runtime(vb): update vb indent plugin as vim9script
Christian Brabandt <cb@256bit.org>
parents:
31579
diff
changeset
|
11 ' Win16=true |
f8e7e00787b5
runtime(vb): update vb indent plugin as vim9script
Christian Brabandt <cb@256bit.org>
parents:
31579
diff
changeset
|
12 #End If |
f8e7e00787b5
runtime(vb): update vb indent plugin as vim9script
Christian Brabandt <cb@256bit.org>
parents:
31579
diff
changeset
|
13 |
31579 | 14 Public Type GEmployeeRecord ' Create user-defined type. |
15 ID As Integer ' Define elements of data type. | |
16 Name As String * 20 | |
17 Address As String * 30 | |
18 Phone As Long | |
19 HireDate As Date | |
20 End Type | |
21 | |
22 Public Enum InterfaceColors | |
23 icMistyRose = &HE1E4FF& | |
24 icSlateGray = &H908070& | |
25 icDodgerBlue = &HFF901E& | |
26 icDeepSkyBlue = &HFFBF00& | |
27 icSpringGreen = &H7FFF00& | |
28 icForestGreen = &H228B22& | |
29 icGoldenrod = &H20A5DA& | |
30 icFirebrick = &H2222B2& | |
31 End Enum | |
32 | |
33 Enum SecurityLevel | |
34 IllegalEntry = -1 | |
35 SecurityLevel1 = 0 | |
36 SecurityLevel2 = 1 | |
37 End Enum | |
38 | |
39 Public Function TestConditional (number As Integer, ext As String) As Boolean | |
40 Dim inRange As Boolean | |
41 | |
42 Select Case number | |
43 Case <= 0 | |
44 inRange = False | |
45 Case > 10 | |
46 inRange = False | |
47 Case Else | |
48 inRange = True | |
49 End Select | |
50 | |
51 ' This is a special case identified in the indent script. | |
52 Select Case number | |
53 End Select | |
54 | |
55 If ext = ".xlm" Then | |
56 If inRange Then | |
57 TestConditional = True | |
58 Else | |
59 TestConditional = False | |
60 End If | |
61 ElseIf ext = ".xlsx" Then | |
62 If inRange Then | |
63 TestConditional = False | |
64 Else | |
65 TestConditional = True | |
66 End If | |
67 Else | |
68 TestConditional = False | |
69 End If | |
70 End Function | |
71 | |
72 Private Sub TestIterators (lLimit As Integer, uLimit As Integer) | |
73 Dim a() As Variant | |
74 Dim elmt As Variant | |
75 Dim found As Boolean | |
76 Dim indx As Integer | |
77 Const specialValue As Integer = 5 | |
78 | |
79 If uLimit < lLimit Then | |
80 Exit Sub | |
81 End If | |
82 | |
83 ReDim a(lLimit To uLimit) | |
84 For indx=lLimit To Ulimit | |
85 a(indx) = 2 * indx | |
86 Next indx | |
87 | |
88 found = False | |
89 For Each elmt in a | |
90 If elmt = specialValue Then | |
91 found = True | |
92 End If | |
93 Next elmt | |
94 | |
95 If found then | |
96 indx = uLimit | |
97 Do While indx >= lLimit | |
98 indx = indx - 1 | |
99 Loop | |
100 End If | |
101 | |
102 End Sub | |
103 | |
104 Public Sub TestMultiline (cellAddr As String, rowNbr As Long) | |
105 Dim rng As Range | |
106 | |
107 Set rng = Range(cellAddr) | |
35225
f8e7e00787b5
runtime(vb): update vb indent plugin as vim9script
Christian Brabandt <cb@256bit.org>
parents:
31579
diff
changeset
|
108 |
f8e7e00787b5
runtime(vb): update vb indent plugin as vim9script
Christian Brabandt <cb@256bit.org>
parents:
31579
diff
changeset
|
109 ' Line continuation is implemented as a two-character sequence- |
f8e7e00787b5
runtime(vb): update vb indent plugin as vim9script
Christian Brabandt <cb@256bit.org>
parents:
31579
diff
changeset
|
110 ' whitespace followed by underscore. |
31579 | 111 With rng |
112 .Cells(1,1).Value = _ | |
113 "Line 1 of multiline string; " & _ | |
114 "Line 2 of multiline string; " & _ | |
115 "Line 3 of multiline string" | |
116 End With | |
117 | |
35225
f8e7e00787b5
runtime(vb): update vb indent plugin as vim9script
Christian Brabandt <cb@256bit.org>
parents:
31579
diff
changeset
|
118 ' This code block omits the leading whitespace character and so |
f8e7e00787b5
runtime(vb): update vb indent plugin as vim9script
Christian Brabandt <cb@256bit.org>
parents:
31579
diff
changeset
|
119 ' the trailing underscore will not be treated as line continuation. |
f8e7e00787b5
runtime(vb): update vb indent plugin as vim9script
Christian Brabandt <cb@256bit.org>
parents:
31579
diff
changeset
|
120 With rng |
f8e7e00787b5
runtime(vb): update vb indent plugin as vim9script
Christian Brabandt <cb@256bit.org>
parents:
31579
diff
changeset
|
121 .Cells(1,1).Value =_ |
f8e7e00787b5
runtime(vb): update vb indent plugin as vim9script
Christian Brabandt <cb@256bit.org>
parents:
31579
diff
changeset
|
122 "Line 1 of multiline string; " &_ |
f8e7e00787b5
runtime(vb): update vb indent plugin as vim9script
Christian Brabandt <cb@256bit.org>
parents:
31579
diff
changeset
|
123 "Line 2 of multiline string; " &_ |
f8e7e00787b5
runtime(vb): update vb indent plugin as vim9script
Christian Brabandt <cb@256bit.org>
parents:
31579
diff
changeset
|
124 "Line 3 of multiline string" |
f8e7e00787b5
runtime(vb): update vb indent plugin as vim9script
Christian Brabandt <cb@256bit.org>
parents:
31579
diff
changeset
|
125 End With |
f8e7e00787b5
runtime(vb): update vb indent plugin as vim9script
Christian Brabandt <cb@256bit.org>
parents:
31579
diff
changeset
|
126 |
f8e7e00787b5
runtime(vb): update vb indent plugin as vim9script
Christian Brabandt <cb@256bit.org>
parents:
31579
diff
changeset
|
127 ' The following lines have whitespace after the underscore character. |
f8e7e00787b5
runtime(vb): update vb indent plugin as vim9script
Christian Brabandt <cb@256bit.org>
parents:
31579
diff
changeset
|
128 ' This is contrary to Microsoft documentation but it is reported that |
f8e7e00787b5
runtime(vb): update vb indent plugin as vim9script
Christian Brabandt <cb@256bit.org>
parents:
31579
diff
changeset
|
129 ' some Microsoft editors allow it and will still treat the statement |
f8e7e00787b5
runtime(vb): update vb indent plugin as vim9script
Christian Brabandt <cb@256bit.org>
parents:
31579
diff
changeset
|
130 ' as line-continued. |
f8e7e00787b5
runtime(vb): update vb indent plugin as vim9script
Christian Brabandt <cb@256bit.org>
parents:
31579
diff
changeset
|
131 With rng |
f8e7e00787b5
runtime(vb): update vb indent plugin as vim9script
Christian Brabandt <cb@256bit.org>
parents:
31579
diff
changeset
|
132 rng.Cells(1,1).Value = _ |
f8e7e00787b5
runtime(vb): update vb indent plugin as vim9script
Christian Brabandt <cb@256bit.org>
parents:
31579
diff
changeset
|
133 "Line 1 of multiline string; " & _ |
f8e7e00787b5
runtime(vb): update vb indent plugin as vim9script
Christian Brabandt <cb@256bit.org>
parents:
31579
diff
changeset
|
134 "Line 2 of multiline string; " & _ |
f8e7e00787b5
runtime(vb): update vb indent plugin as vim9script
Christian Brabandt <cb@256bit.org>
parents:
31579
diff
changeset
|
135 "Line 3 of multiline string" |
f8e7e00787b5
runtime(vb): update vb indent plugin as vim9script
Christian Brabandt <cb@256bit.org>
parents:
31579
diff
changeset
|
136 End With |
31579 | 137 |
138 End Sub | |
139 | |
140 Private Sub TestStmtLabel() | |
141 GoTo stmtLabel | |
142 | |
143 ' Statement labels are never indented | |
144 stmtLabel: | |
145 | |
146 End Sub | |
147 | |
35225
f8e7e00787b5
runtime(vb): update vb indent plugin as vim9script
Christian Brabandt <cb@256bit.org>
parents:
31579
diff
changeset
|
148 Public Static Function TestStatic(addend As Integer) |
f8e7e00787b5
runtime(vb): update vb indent plugin as vim9script
Christian Brabandt <cb@256bit.org>
parents:
31579
diff
changeset
|
149 Dim Integer accumulator |
f8e7e00787b5
runtime(vb): update vb indent plugin as vim9script
Christian Brabandt <cb@256bit.org>
parents:
31579
diff
changeset
|
150 accumulator = accumulator + addend |
f8e7e00787b5
runtime(vb): update vb indent plugin as vim9script
Christian Brabandt <cb@256bit.org>
parents:
31579
diff
changeset
|
151 TestStatic = accumulator |
f8e7e00787b5
runtime(vb): update vb indent plugin as vim9script
Christian Brabandt <cb@256bit.org>
parents:
31579
diff
changeset
|
152 End Function |
f8e7e00787b5
runtime(vb): update vb indent plugin as vim9script
Christian Brabandt <cb@256bit.org>
parents:
31579
diff
changeset
|
153 |
f8e7e00787b5
runtime(vb): update vb indent plugin as vim9script
Christian Brabandt <cb@256bit.org>
parents:
31579
diff
changeset
|
154 Friend Function TestFriend(addend As Integer) |
f8e7e00787b5
runtime(vb): update vb indent plugin as vim9script
Christian Brabandt <cb@256bit.org>
parents:
31579
diff
changeset
|
155 Static Integer accumulator |
f8e7e00787b5
runtime(vb): update vb indent plugin as vim9script
Christian Brabandt <cb@256bit.org>
parents:
31579
diff
changeset
|
156 accumulator = accumulator + addend |
f8e7e00787b5
runtime(vb): update vb indent plugin as vim9script
Christian Brabandt <cb@256bit.org>
parents:
31579
diff
changeset
|
157 TestFriend = accumulator |
f8e7e00787b5
runtime(vb): update vb indent plugin as vim9script
Christian Brabandt <cb@256bit.org>
parents:
31579
diff
changeset
|
158 End Function |
f8e7e00787b5
runtime(vb): update vb indent plugin as vim9script
Christian Brabandt <cb@256bit.org>
parents:
31579
diff
changeset
|
159 |
31579 | 160 Sub TestTypeKeyword() |
161 Type EmployeeRecord ' Create user-defined type. | |
162 ID As Integer ' Define elements of data type. | |
163 Name As String * 20 | |
164 Address As String * 30 | |
165 Phone As Long | |
166 HireDate As Date | |
167 End Type | |
168 Dim varType As EmployeeRecord | |
169 End Sub | |
35225
f8e7e00787b5
runtime(vb): update vb indent plugin as vim9script
Christian Brabandt <cb@256bit.org>
parents:
31579
diff
changeset
|
170 |
f8e7e00787b5
runtime(vb): update vb indent plugin as vim9script
Christian Brabandt <cb@256bit.org>
parents:
31579
diff
changeset
|
171 Sub TestDateLiteralAfterLineContinuation |
f8e7e00787b5
runtime(vb): update vb indent plugin as vim9script
Christian Brabandt <cb@256bit.org>
parents:
31579
diff
changeset
|
172 Dim birthday as Date |
f8e7e00787b5
runtime(vb): update vb indent plugin as vim9script
Christian Brabandt <cb@256bit.org>
parents:
31579
diff
changeset
|
173 birthday = _ |
f8e7e00787b5
runtime(vb): update vb indent plugin as vim9script
Christian Brabandt <cb@256bit.org>
parents:
31579
diff
changeset
|
174 #January 1, 1901# |
f8e7e00787b5
runtime(vb): update vb indent plugin as vim9script
Christian Brabandt <cb@256bit.org>
parents:
31579
diff
changeset
|
175 End Sub |
31579 | 176 ' END_INDENT |