http://forums.esri.com/Thread.asp?c=93&f=993&t=210767&mc=12#652601
Option Explicit
Sub TestInMemory()
Dim pFC As IFeatureClass
Set pFC = OpenFC(“C:\Projects\SAWS\water3.gdb”, _
“Mains”)
Dim pFLayer As IFeatureLayer
Set pFLayer = New FeatureLayer
pFLayer.Name = pFC.AliasName
Set pFLayer.FeatureClass = CacheToMemory(pFC, “Shape_Length 0 Then
Set pQF = New QueryFilter
pQF.WhereClause = sWhere
End If
Dim pInFCur As IFeatureCursor
Set pInFCur = pFC.Search(pQF, False)
Dim pFeat As IFeature
Set pFeat = pInFCur.NextFeature
Do Until pFeat Is Nothing
Dim pOutFeat As IFeature
Set pOutFeat = pInMemFC.CreateFeature
Dim l As Long
For l = 0 To pOutFeat.Fields.FieldCount – 1
‘ todo maybe search by field alias to find match
If pOutFeat.Fields.Field(l).Editable Then
pOutFeat.Value(l) = pFeat.Value(l)
End If
Next l
pOutFeat.Store
Set pFeat = pInFCur.NextFeature
Loop
End Sub
Function Clone(pClone As IClone) As IClone
Set Clone = pClone.Clone
End Function
Function OpenFC(sPath As String, sName As String) As IFeatureClass
Dim pWSF As IWorkspaceFactory
Set pWSF = New FileGDBWorkspaceFactory
Dim pFWS As IFeatureWorkspace
Set pFWS = pWSF.OpenFromFile(sPath, 0)
Set OpenFC = pFWS.OpenFeatureClass(sName)
End Function