资源描述:
《用vb做文本编辑器(using vb as text editor)》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、用vb做文本编辑器(UsingVBastexteditor)ItmeansmakinganotepadLookatthefollowingIt'snotcomplicatedtomakeanotepadwithVB.Wecandoiteasilybythewizard.ButthisarticleisjustgoingtotalkaboutmakingNotepadmanually,toshowtoVBBeginners:it'ssoeasytolearnVB!Byreading,thispaperaccordingtotheexperiment
2、,beginnerswilllearnalotofthings,suchashowtousetheRichTextcontroltoopenandsavethefile,howtomakeamenu,toolbarandstatusbarandhowtowritecode.ChapteroneletourNotepadrunrightawayEagerforsuccessisthecommonaspirationofbeginners.Well,pleasedothefollowingthreesteps,andourwishescanberea
3、lizedimmediately!Stepone:drawtheinterface.CreateastandardEXEproject,changeitsCaptionattributeto"superNOTEPAD",andclicktheIconattributetofindasuitableIconiconforit.Clickthemenu"project"-"component",inthepop-up"component"dialogbox,findMicrosoftRichTextBox6andpublicdialogboxMicr
4、osoftCommonDialog6andselectthem,clickthe"OK"button.Whenthelefttoolbarappearstwocontrolswejustadded.RichTextBoxandCommnDialogdrawingontheform,thesizeandlocationofRichTextBoxcannotbeignored,wewilldealwithitinthecode,ofcourse,itisnecessarytoputitsScrollBarpropertyto2-rtfVertical
5、,sointheopenandeditfilescanbeusedwhentheverticalscrollbar.Steptwo:editthemenu.TobringupthemenueditorbyCtrl+E,let'sdothefollowingmenus:Filemenu:File(layer1)mnuFileNew(secondlayer)mnuNewOpen(secondlayer)mnuOpenSave(secondlayers)mnuSave-(secondlayers)mnuFileSep(dividingline)Exit
6、(secondlayer)mnuExitTwo.Editmenu:Editor(layer1)mnuEditCopy(secondlayers)mnuCopyShear(secondlayer)mnuCutPaste(secondlayers)mnuPaste-(secondlayers)mnuEditSep(dividingline)Select(second)mnuSelecAllThree.Searchmenu:Search(layer1)mnuSearchFind(secondlayers)mnuFindFindthenext(secon
7、dlayer)mnuFindOnFour.Helpmenu:Help(layer1)mnuHelpInstructions(secondlayers)mnuUsageAbout(secondlayers)mnuAbout(Note:shortcutkeysforeachmenuitemaresetbythemselves)OK,othermenuitemswillbeaddedassoonasneeded.Enternow:Stepthree:writecode.'declarelookupvariablesDimsFindAsStringSta
8、tementfiletypeDimFileType,FiTypeAsStringInitializationprogramPrivate