弹来弹去跑马灯!

VB6 XArrayDB | Xarray ReDim 用法


用法解释

官方解释:http://helpcentral.componentone.com/nethelp/truedblist8/default.htm#!redimmethodxarraydb.htm

XArrayDB Reference / XArrayDB Object Methods
ReDim Method (XArrayDB)

This method is used to set or reset the dimensions of an XArrayDB object while preserving any existing data.
Syntax
XArrayDB.ReDimrowLB, rowUB, columnLB, columnUB(解释)
Arguments
rowLB and rowUB are long integers specifying the lower and upper bounds for row indexes.
columnLB and columnUB are long integers specifying the lower and upper bounds for column indexes.
Return Value
None
Remarks
Method applies to XArrayDB object.
Since a newly created XArrayDB object does not have any default dimensions, you must use the ReDim method before you can assign or access array elements.
Example
The following example creates and initializes a two-dimensional XArrayDB object. The first dimension has 100 elements, with indexes starting at 1 and ending at 100. The second dimension has 6 elements, with indexes starting at 0 and ending at 5.
Dim MyArray As New XArrayDB
MyArray.ReDim 1, 100, 0, 5


例子绑定用 XArray绑定 TDBGrid

Dim X As New XArray
Private Sub Form_Load()
Dim r As Integer
Dim c As Integer
Dim clmn As TrueDBGrid80.Column‘列
r = 9 'row
c = 5 'column
X.ReDim 0, r, 0, c
TDBGrid1.Columns.Clear
For k = 0 To c
Set clmn = TDBGrid1.Columns.Add(k)'动态添加列
clmn.Visible = True
clmn.Caption = "column " & k
Next k
Call FillXArray(r, c)‘填充数据
Set Me.TDBGrid1.Array = X
Me.TDBGrid1.ReBind
End Sub
Private Sub FillXArray(intI As Integer, intJ As Integer)’填充数据
On Error Resume Next
Dim I As Integer
Dim j As Integer
Dim k As Integer

For I = 0 To intI
    For j = 0 To intJ
        X(I, j) = " row:" & I & ",column" & j
        If Err Then Exit For
    Next j
    If Err Then Exit For
Next I

If (Err.Number <> 0) Then
MsgBox Err.Description
End If
End Sub

posted @ 2016-02-24 11:21  wgscd  阅读(1934)  评论(0编辑  收藏  举报