A macro that generates an attribute.

Source: Internet
Author: User

After executing this macro, a form will pop up. Enter the type and name in the two Textbox, and the form will be automatically added in the editing area.

Private   Int Typeid;

Public   Int Typeid
{
Get   {Return This. Typeid ;}
Set   {This. Typeid=Value ;}
}

Such a property, such as a complete macro, is super depressing why the macro cannot be written in C.

Sub propertygenerator () Sub Propertygenerator ()

Dim Form As Form

Form =   New Form

Form. topmost =   True

Form. Controls. Add ( New Textbox)
Form. Controls. Add ( New Textbox)

Form. Controls ( 0 ). Text =   " Type"
Form. Controls ( 1 ). Text =   " Name"
Form. Controls ( 0 ). Dock = Dockstyle. Bottom
Form. Controls ( 1 ). Dock = Dockstyle. Bottom

Form. showdialog ()

Dim Type As   String
Dim Name As   String
Dim Capitaledname As   String

Type = Form. Controls ( 0 ). Text
Name = Form. Controls ( 1 ). Text
Capitaledname =   Char . Toupper (name. Chars ( 0 )) & Name. substring ( 1 )

Form =   Nothing

DTE. activedocument. selection. Text =   " Private "   & Type &   "   "   & Name &   " ;"
DTE. activedocument. selection. newline ()
DTE. activedocument. selection. newline ()
DTE. activedocument. selection. Text =   " Public "   & Type &   "   "   & Capitaledname &   " "
DTE. activedocument. selection. newline ()
DTE. activedocument. selection. Text =   " {"
DTE. activedocument. selection. newline ()
DTE. activedocument. selection. Text =   " Get {return this. "   & Name &   " ;}"
DTE. activedocument. selection. newline ()
DTE. activedocument. selection. Text =   " Set {This. "   & Name &   " = Value ;}"
DTE. activedocument. selection. newline ()
DTE. activedocument. selection. Text =   " }"
DTE. activedocument. selection. newline ()

End sub Dim Line As   String

With DTE. activedocument. Selection
Line = . Text
End   With

Dim Parts As   String ()

Parts = Line. Split ( "   " )

If   Not Parts. Length =   3   Then
Exit sub
End   If

Dim Type As   String
Dim Name As   String
Dim Capitaledname As   String

Type = Parts ( 1 )
Name = Parts ( 2 ). Replace ( " ; " , "" )
Capitaledname =   Char . Toupper (name. Chars ( 0 )) & Name. substring ( 1 )

DTE. activedocument. selection. Text =   " Private "   & Type &   "   "   & Name &   " ;"
DTE. activedocument. selection. newline ()
DTE. activedocument. selection. newline ()
DTE. activedocument. selection. Text =   " Public "   & Type &   "   "   & Capitaledname &   " "
DTE. activedocument. selection. newline ()
DTE. activedocument. selection. Text =   " {"
DTE. activedocument. selection. newline ()
DTE. activedocument. selection. Text =   " Get {return this. "   & Name &   " ;}"
DTE. activedocument. selection. newline ()
DTE. activedocument. selection. Text =   " Set {This. "   & Name &   " = Value ;}"
DTE. activedocument. selection. newline ()
DTE. activedocument. selection. Text =   " }"
DTE. activedocument. selection. newline ()

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.