该范例使用 NumericScale 和 Precision 属性来显示在 Pubs 数据库 Discounts 表中字段的数值范围和精度。
Public Sub NumericScaleX() Dim rstDiscounts As ADODB.Recordset Dim fldTemp As ADODB.Field Dim strCnn As String ' 打开记录集。 strCnn = "Provider=sqloledb;" & _ "Data Source=srv;Initial Catalog=pubs;User Id=sa;Password=; " Set rstDiscounts = New ADODB.Recordset rstDiscounts.Open "discounts", strCnn, , , adCmdTable ' 显示数字和小整数字段的数值范围和精度。 For Each fldTemp In rstDiscounts.Fields If fldTemp.Type = adNumeric _ Or fldTemp.Type = adSmallInt Then MsgBox "Field: " & fldTemp.Name & vbCr & _ "Numeric scale: " & _ fldTemp.NumericScale & vbCr & _ "Precision: " & fldTemp.Precision End If Next fldTemp rstDiscounts.CloseEnd Sub