VBA/Excel/Access/Word/Data Type Functions/LBound UBound

Материал из VB Эксперт
Перейти к: навигация, поиск

Use LBound function to get lower bound

 
Sub Array1()
  Dim Data(10) As Integer
  Dim Message As String, i As Integer
  For i = LBound(Data) To UBound(Data)
    Data(i) = i
  Next i
  MsgBox "Lower Bound = " & LBound(Data) & vbCr
End Sub



Use UBound to get the upper bound

 
Sub Array2()
  Dim Data(10) As Integer
  Dim Message As String, i As Integer
  For i = LBound(Data) To UBound(Data)
    Data(i) = i
  Next i
  MsgBox "Upper Bound = " & UBound(Data) & vbCr
End Sub