I'm trying to create a point IFeatureClass, but my code doesn't work.
Public Function CreatePointFeatureClass(ByVal featureClassName As String, _
ByVal featureWorkspace As IFeatureWorkspace) As IFeatureClass
' Instantiate a feature class description to get the required fields.
Dim fcDescription As IFeatureClassDescription = New FeatureClassDescriptionClass()
Dim ocDescription As IObjectClassDescription = CType(fcDescription, IObjectClassDescription)
Dim fields As IFields = New FieldsClass
Dim fieldsEdit As IFieldsEdit = CType(fields, IFieldsEdit)
Dim fieldUserDefined As IField = New FieldClass
Dim fieldEdit As IFieldEdit = CType(fieldUserDefined, IFieldEdit)
' Set up geometry definition for the Shape field.
' You do not have to set the spatial reference, as it is inherited from the feature dataset.
Dim geometryDef As IGeometryDef = New GeometryDefClass
Dim geometryDefEdit As IGeometryDefEdit = CType(geometryDef, IGeometryDefEdit)
' By setting the grid size to 0, you are allowing ArcGIS to determine the appropriate grid sizes for the feature class.
' If in a personal geodatabase, the grid size is 1,000. If in a file or ArcSDE geodatabase, the grid size
' is based on the initial loading or inserting of features.
geometryDefEdit.GeometryType_2 = ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPoint
' Set standard field properties.
fieldEdit.Name_2 = "SHAPE"
fieldEdit.Type_2 = esriFieldType.esriFieldTypeGeometry
fieldEdit.GeometryDef_2 = geometryDefEdit
fieldEdit.IsNullable_2 = True
fieldEdit.Required_2 = True
fieldsEdit.AddField(fieldUserDefined)
' Add a X Double field to the required fields.
Dim field1 As IField = New FieldClass()
Dim fieldEdit1 As IFieldEdit = CType(field1, IFieldEdit)
fieldEdit1.Name_2 = "X"
fieldEdit1.Type_2 = esriFieldType.esriFieldTypeDouble
fieldsEdit.AddField(field1)
' Add a Y Double field to the required fields.
Dim field2 As IField = New FieldClass()
Dim fieldEdit2 As IFieldEdit = CType(field2, IFieldEdit)
fieldEdit2.Name_2 = "Y"
fieldEdit2.Type_2 = esriFieldType.esriFieldTypeDouble
fieldsEdit.AddField(field2)
' Add a Elevation Double field to the required fields.
Dim field3 As IField = New FieldClass()
Dim fieldEdit3 As IFieldEdit = CType(field3, IFieldEdit)
fieldEdit3.Name_2 = "Elevation"
fieldEdit3.Type_2 = esriFieldType.esriFieldTypeDouble
fieldsEdit.AddField(field3)
' Use IFieldChecker to create a validated fields collection.
Dim fieldChecker As IFieldChecker = New FieldCheckerClass()
Dim enumFieldError As IEnumFieldError = Nothing
Dim validatedFields As IFields = Nothing
fieldChecker.ValidateWorkspace = CType(featureWorkspace, IWorkspace)
fieldChecker.Validate(fields, enumFieldError, validatedFields)
' The enumFieldError enumerator can be inspected at this point to determine
' which fields were modified during validation.
' Create the feature class.
Dim featureClass As IFeatureClass = featureWorkspace.CreateFeatureClass(featureClassName, validatedFields, _
ocDescription.InstanceCLSID, ocDescription.ClassExtensionCLSID, esriFeatureType.esriFTSimple, _
"SHAPE", "")
Return featureClass
End Function