Well, its not that easy...Pending which version as well, 9.3 prior, you must make the toolbar/button with IToolbarDef code... then its hooking to the application from there... registering the dll using regasm32 on a windows xp machineIf you are using 10, you then use addins, now you have to write the XML and such...You will notice .THISdocument is now replaced wtih namespace MY when using addins...Here is your converted code, but unfortunately, its not just going to be a copy paste, publish and it works. There is more involved. e.g. Gathering the references associating the class into ArcMap etc.... button etc.Not sure, but your code is just simply adding a field, perhaps a model would suit you better.Imports System.Windows.Forms
Imports ESRI.ArcGIS.ArcMapUI
Imports ESRI.ArcGIS.Carto
Imports ESRI.ArcGIS.Geodatabase
Public Class Class1
Sub AddField_Name1()
Try
'
'
Dim pMxDoc As IMxDocument
Dim pLayer As ILayer
Dim pFLayer As IFeatureLayer
Dim pFeatClass As IFeatureClass
Dim NewField As IFieldEdit
Dim strFieldName As String
Dim intFieldType As Integer
Dim intLength As Integer
'
'
'Verweis auf das aktuelle Dokument
pMxDoc = My.ArcMap.Document 'ThisDocument
'
pLayer = pMxDoc.SelectedLayer
If pLayer Is Nothing Then
MessageBox.Show("Achtung, es ist kein Layer selektiert", "", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
Exit Sub
End If
pFLayer = pLayer
pFeatClass = pFLayer.FeatureClass
'
' Eingabe der Feldnamen
strFieldName = "Name1"
'
'
NewField = New Field
With NewField
.Length_2 = 75
.Type_2 = esriFieldType.esriFieldTypeString
.Name_2 = strFieldName
End With
'
' Kontrolle, ob Feldname schon vorhanden
If pFeatClass.FindField(strFieldName) > -1 Then
MessageBox.Show("Das Feld '" & strFieldName & "' ist bereits vorhanden, bitte anderen Feldnamen angeben!", "", MessageBoxButtons.OK, MessageBoxIcon.Information)
Exit Sub
Else
MessageBox.Show( "Das Feld '" & strFieldName & "' ist noch nicht vorhanden und wird erzeugt!")
End If
'
pFeatClass.AddField(NewField) 'Neues Feld wird hinzugefügt
'
Catch ex As Exception
MessageBox.Show("Es ist ein Fehler aufgetreten, das Programm wird beendet!", "", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub
End Class