Example of Accessing the Repository by Using Visual Basic

This example gets information for the class ABS_HIST from the Namespace component interface.

Private Sub Command1_Click()
    '**************************************************************
    '* TacDemo: Example Repository Usage from Visual Basic
    '*
    '* Copyright (c) 1999 PeopleSoft, Inc.  All rights reserved

    '**************************************************************
    ' Declare variables
    Dim oSession As New PeopleSoft_PeopleSoft.Session
    Dim oPSMessages As PSMessageCollection
    Dim oPSMessage As PSMessage
    ' Establish a PeopleSoft Session
    nStatus = oSession.Connect(1, "//PSOFTO070698:9001", "PTDMO", "PTDMO", 0)
    ' Enable error-handler
    On Error GoTo ErrorHandler
    ' Get a Component Interface "shell"
    Dim oNamespaces As NamespaceCollection
    Dim oNamespace As Namespace
    Dim oClasses As ClassInfoCollection
    Dim oClass As ClassInfo
    Dim oMethods As MethodInfoCollection
    Dim oMethod As MethodInfo
    Dim oArguments As PropertyInfoCollection
    Dim oArgument As PropertyInfo
    Dim oProperties As PropertyInfoCollection
    Dim oProperty As PropertyInfo
    Set oNamespaces = oSession.Repository.namespaces
    Set oNamespace = oNamespaces.ItemByName("ComponentInterface")
    Dim outText As String
    outText = "Namespace = " & oNamespace.Name & vbNewLine
    Set oClasses = oNamespace.classes
    Set oClass = oClasses.ItemByName("ABS_HIST")
    outText = outText & "   Class: " & oClass.Name & vbNewLine
    outText = outText & "       Methods" & vbNewLine
    Set oMethods = oClass.methods
    For k = 0 To oMethods.Count - 1
        Set oMethod = oMethods.Item(k)        outText = outText & "           " 
& oMethod.Name & ":  " & oMethod.Type & vbNewLine
        Set oArguments = oMethod.arguments
        For m = 0 To oArguments.Count - 1
            Set oArgument = oArguments.Item(m)
            outText = outText & "                 " 
& oArgument.Name & ":  " & oArgument.Type & vbNewLine
        Next
    Next
    outText = outText & "       Properties" & vbNewLine
    Set oProperties = oClass.properties
    For k = 0 To oProperties.Count - 1
        Set oProperty = oProperties.Item(k)
        outText = outText & "            " & oProperty.Name & ":  " 
& oProperty.Type & vbNewLine
    Next
 txtResults = outText
' Leave before we encounter the error handler
Exit Sub
ErrorHandler:
    If Err.Number = 1001 Then                ' PeopleSoft Error
        Set oPSMessages = oSession.PSMessages
        If oPSMessages.Count > 0 Then
            For i = 1 To oPSMessages.Count
               Set oPSMessage = oPSMessages.Item(i)
               MsgBox (oPSMessage.Text)
            Next i
            oPSMessages.DeleteAll
        Else
            MsgBox ("PS Api Error. No additional information 
available from Session log")
        End If
    Else                                    ' VB Error
        MsgBox ("VB Error: " & Err.Description)
    End If
End Sub