LCFieldlist の Lookup メソッド

このメソッドは、フィールド名に基づいて、フィールドリストからフィールドを検索します。

定義位置

LCFieldlist

構文

Set field = fldListRecord. Lookup (fieldName, index)

パラメータ

パラメータ

説明

fieldName

String 型。検索するフィールドの名前です。

index

Long。出力 (オプション)。フィールドの位置です。

戻り値

説明

field

LCField。このリストでの名前が fieldName に指定された名前であるフィールドです。このようなフィールドが存在しない場合は、Nothing が返されます。

Option Public
Uselsx "*lsxlc" 
Sub Initialize
  Dim connect As New LCConnection ("db2") 
  Dim FldLst As New LCFieldlist
  Dim field As LCField
  Dim pos As Long
  REM this section assigns the appropriate properties to connect to DB2
  connect.Database = "Gold"
  connect.Userid = "JDoe"
  connect.Password = "xyzzy"
  connect.Metadata = "customer"
  REM connect to DB2
  connect.Connect
  REM now perform the catalog action - in this case for fields
  If (connect.Select (Nothing, 1, FldLst) = 0) Then
    Print "The customer table was not found."
  Else
    Set field = FldLst.Lookup ("contactname", pos)
    If Not (field Is Nothing) Then
      Print "Found 'ContactName' in the fieldlist at position " & pos
    Else
      Print "Did not find 'ContactName' in the fieldlist."
    End If
  End If
End Sub

出力例

Found 'ContactName' in the fieldlist at position 2