Banale, lo so... ma dopo 3 volte che riscrivo le stesse cose mi viene l'orticaria!
E così intanto provo anche IMHO...
Sub WriteSimpleVBProperty() Dim propertyName As String = String.Empty Dim privateMember As String = String.Empty Dim propertyType As String = "String" propertyName = InputBox("Property name:", "WriteSimpleVBProperty", propertyName) privateMember = InputBox("Private member:", "WriteSimpleVBProperty", privateMember) propertyType = InputBox("Property type:", "WriteSimpleVBProperty", propertyType) Dim fx As New System.Text.StringBuilder fx.Append(String.Format(" Private {0} As {1}", privateMember, propertyType)) Select Case propertyType.ToLower Case "string" fx.Append(" = String.Empty") Case "date", "datetime" fx.Append(" = DateTime.MinValue") End Select fx.Append(ControlChars.Cr) fx.Append(String.Format(" Public Property {0}() As {1}", propertyName, propertyType)) fx.Append(ControlChars.Cr) fx.Append(" Get") fx.Append(ControlChars.Cr) fx.Append(String.Format(" Return {0}", privateMember)) fx.Append(ControlChars.Cr) fx.Append(" End Get") fx.Append(ControlChars.Cr) fx.Append(String.Format(" Set(ByVal Value As {0})", propertyType)) fx.Append(ControlChars.Cr) fx.Append(String.Format(" {0} = Value", privateMember)) fx.Append(ControlChars.Cr) fx.Append(" End Set") fx.Append(ControlChars.Cr) fx.Append(" End Property") fx.Append(ControlChars.Cr) DTE.ActiveDocument.Selection.TopPoint.CreateEditPoint.Insert(fx.ToString) fx = Nothing End Sub
powered by IMHO