Dear ,
In an attribute table of shp file,
I want to convert a field (Double) (GID1) to a field (string) (GID4) using VBA.
Cstr was tried but failed.
Pls kindly help and thanks
code
Public Sub AddCalcField()
Dim pMxDoc As IMxDocument
'Dim pFLayer As IGeoFeatureLayer
Dim pFLayer As IFeatureLayer
Dim pFClass As IFeatureClass
Dim pField As IFieldEdit
Dim dt As String
Dim db As Double
Set pMxDoc = ThisDocument
Set pFLayer = pMxDoc.FocusMap.Layer(0)
Set pFClass = pFLayer.FeatureClass
Set pField = New Field
' Adding new Real Estate Tax field and converts to integer
pField.Name = "GID4"
pField.Type = esriFieldTypeString
pField.Length = 10
pFClass.AddField pField
intRTax1 = pFClass.FindField("GID")
intRTax2 = pFClass.FindField("GID4")
intRTax2 = CStr(intRTax1)
Dim pFeature As IFeature
Dim pFCursor As IFeatureCursor
Set pFCursor = pFClass.Update(Nothing, False)
Set pFeature = pFCursor.NextFeature
'Loops through the attribute table and updates null values for new R_TAX field
Do Until pFeature Is Nothing
pFeature.Value(intRTax2) = Val(pFeature.Value(intRTax1))
pFCursor.UpdateFeature pFeature
Set pFeature = pFCursor.NextFeature
Loop
End Sub