Create a new object class

Description:

This sample will demonstrate the steps needed to create a new geodatabase object class.

How to use:
  1. Paste the code into your VB or VBA Application.
  2. Call the function from within your application.
''
'' create a object class, table, inside a dataset
''
Public Function createObjectClass(pFWS As esriCore.IFeatureWorkspace, _
                                  strName As String, _
                                  Optional pFields As esriCore.IFields) as esricore.IObjectClass
  
  On Error GoTo EH
  If pFWS Is Nothing Then Exit Function
  
  '' create the behavior clasid for the featureclass
  Dim pCLSID As esriCore.UID
  Set pCLSID = New esriCore.UID
  pCLSID.Value = "esricore.Object"
  
  ' if a fields collection is not passed in then supply our own
 If (pfields Is Nothing) Or IsMissing(pfields)  Then
    ' create the fields used by our object
    Set pFields = New esriCore.fields
    Dim pFieldsEdit As esriCore.IFieldsEdit
    Set pFieldsEdit = pFields
    Dim pFieldEdit As esriCore.IFieldEdit
    pFieldsEdit.FieldCount = 1
    
    '' create the OID field
    Dim pFieldOID As esriCore.IField
    Set pFieldOID = New esriCore.Field
    Set pFieldEdit = pFieldOID
    pFieldEdit.Name = "OBJECTID"
    pFieldEdit.Type = esriFieldTypeOID
    pFieldEdit.IsNullable = False
    Set pFieldsEdit.Field(0) = pFieldOID
  End If
  
  set createobjectclass = pFWS.CreateTable( strName, pFields, pCLSID, Nothing, "")
  
  Exit Function
EH:
    MsgBox Err.Description, vbInformation, "createDatasetFeatureClass"
End Function