ActualSize and DefinedSize Properties Example

This example uses the ActualSize and DefinedSize properties to display the defined size and actual size of a field.

Public Sub ActualSizeX()

   Dim rstStores As ADODB.Recordset
   Dim strCnn As String

   ' Open a recordset for the Stores table.
   strCnn = "Provider=sqloledb;" & _
      "Data Source=srv;Initial Catalog=pubs;User Id=sa;Password=; "
   Set rstStores = New ADODB.Recordset
   rstStores.Open "stores", strCnn, , , adCmdTable
   
   ' Loop through the recordset displaying the contents
   ' of the stor_name field, the field's defined size,
   ' and its actual size.
   rstStores.MoveFirst

   Do Until rstStores.EOF
      MsgBox "Store name: " & rstStores!stor_name & _
      vbCr & "Defined size: " & _
      rstStores!stor_name.DefinedSize & _
      vbCr & "Actual size: " & _
      rstStores!stor_name.ActualSize & vbCr
      rstStores.MoveNext
   Loop

   rstStores.Close

End Sub