Set pFieldsEdit = featLayer.FeatureClass.Fields
strFieldInfo = ""
Set pField = New Field
Set pFieldEdit = pField
With pFieldEdit
.Name = txtFieldname.Text
strFieldInfo = strFieldInfo & "字段名: " & txtFieldname.Text
.Type = setFieldType(cmb_FieldType.Text)
strFieldInfo = strFieldInfo & Chr(13) & "字段类型: " & cmb_FieldType.Text
If txt_precision.Text <> "" Then
.Precision = Val(txt_precision.Text)
strFieldInfo = strFieldInfo & Chr(13) & "有效数字位数: " & txt_precision.Text
End If
If txt_Scale.Text <> "" Then
.Scale = Val(txt_Scale.Text)
strFieldInfo = strFieldInfo & Chr(13) & "小数点位数: " & txt_Scale.Text
End If
.IsNullable = chk_NullAble.value
If chk_NullAble.value = 0 Then
strFieldInfo = strFieldInfo & Chr(13) & "是否允许为空: " & "否"
ElseIf chk_NullAble.value = 1 Then
strFieldInfo = strFieldInfo & Chr(13) & "是否允许为空: " & "是"
End If
End With
'要求用户再确认一次字段的信息
flag = MsgBox("你确定要添加该字段吗?" & Chr(13) & strFieldInfo, vbOKCancel)
If flag = vbOK Then
pFieldsEdit.addField pField
txt_precision.Text = ""
txt_Scale.Text = ""
txtFieldname = ""
End If
txtFieldname.SetFocus
txtFieldname.SelStart = 0
txtFieldname.SelLength = Len(txtFieldname.Text)