Click or drag to resize
GetCustomerAddress function

This example retrieves address information from a BC Meridian table.

Visual Basic 6
Private Function GetCustomerData(ByVal CustomerName As String)
  On Error Goto errh
  Dim x
  Dim phone
  Dim address
  x = m_Designer.VaultDetails.Table("Customers").GetValues("CustomerName", CustomerName, Array("CustomerPhone","CustomerAddress"))

  'If the customer was found, retrieve values of the columns
  If IsArray(x) Then
    phone = x(0, 0)
    address = x(1,0)
    GetCustomerData = Array(phone, address)
  Else
    'If the customer was not found, return nothing
    GetCustomerData = Nothing
  End If

  Exit Function

errh:
  MsgBox "Error in GetCustomerData:"  & Err.Description
  GetCustomerData = Nothing
End Function
Visual Basic .NET
Private Function GetCustomerData(ByVal CustomerName As String) As String() 
  Try 
    If ExtensionHost IsNot Nothing Then 
      Using table As BCSTable = ExtensionHost.ScriptObjects.Vault.Table("Customers") 
        Dim matchColumns() As String = {"CustomerName"}
        Dim matchValues() As String = {CustomerName} 
        Dim outColumns As String() = {"CustomerPhone","CustomerAddress"}
        Dim x = table.GetValues(matchColumns, matchValues, outColumns) 
        'If the customer was found, retrieve values of the columns
        If x.Length >= 1 Then 
          Dim phone = x(0,0).ToString
          Dim address = x(1,0).ToString
          Return New String() {phone, address} 
        End If 
      End Using 
    End If 

  Catch ex As Exception 
    MsgBox("Error in GetCustomerData:" + ex.ToString()) 
  End Try

  'If the customer was not found, return nothing
  Return Nothing 
End Function
See Also