zoukankan      html  css  js  c++  java
  • 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

  • 相关阅读:
    Windows API 的数据类型与 Delphi 数据类型对照表
    Delphi 编译错误信息表
    Delphi中的容器类
    Delphi 快捷键
    代码折叠
    [转]Delphi中record的使用
    [转]常用公共函数单元
    Delphi 运行时错误信息表
    C#调用Win32 的API函数User32.dll
    [转]Delphi程序启动参数的读取
  • 原文地址:https://www.cnblogs.com/wgscd/p/5212313.html
Copyright © 2011-2022 走看看