vb.ok 3.1 KB

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