vim

Fork of vim, an acceptable text editor
git clone git://git.laack.co/vim.git
Log | Files | Refs | README | LICENSE

vb.in (3568B)


      1 ' vim: filetype=vb shiftwidth=4 expandtab
      2 '
      3 ' START_INDENT
      4 #Const Debug = False
      5 
      6 #If Win64 Then
      7 ' Win64=true, Win32=true, Win16=false
      8 #ElseIf Win32 Then
      9 ' Win32=true, Win16=false
     10 #Else
     11 ' Win16=true
     12 #End If
     13 
     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)
    108 
    109 ' Line continuation is implemented as a two-character sequence-
    110 ' whitespace followed by underscore.
    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 
    118 ' This code block omits the leading whitespace character and so 
    119 ' the trailing underscore will not be treated as line continuation.
    120 With rng
    121 .Cells(1,1).Value =_
    122 "Line 1 of multiline string; " &_
    123 "Line 2 of multiline string; " &_
    124 "Line 3 of multiline string"
    125 End With
    126 
    127 ' The following lines have whitespace after the underscore character.
    128 ' This is contrary to Microsoft documentation but it is reported that
    129 ' some Microsoft editors allow it and will still treat the statement
    130 ' as line-continued.  
    131 With rng
    132 rng.Cells(1,1).Value = _ 
    133 "Line 1 of multiline string; " & _ 
    134 "Line 2 of multiline string; " & _ 
    135 "Line 3 of multiline string"
    136 End With
    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 
    148 Public Static Function TestStatic(addend As Integer)
    149 Dim Integer accumulator
    150 accumulator = accumulator + addend
    151 TestStatic = accumulator
    152 End Function
    153 
    154 Friend Function TestFriend(addend As Integer)
    155 Static Integer accumulator
    156 accumulator = accumulator + addend
    157 TestFriend = accumulator
    158 End Function
    159 
    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
    170 
    171 Sub TestDateLiteralAfterLineContinuation
    172 Dim birthday as Date
    173 birthday = _
    174 #January 1, 1901#
    175 End Sub
    176 ' END_INDENT