关于语法高亮,有什么快速的办法?
用 RichTextBox 做 vb 语法高亮处理,只处理关键字与注释行,不做语法检查。已写出代码可以处理,但速度不理想。
哪位大虾有好的做法或优化建议?
这是我的代码:
Private Const vbKeyWords As String = "And,Call,Case,Const,Dim,Do,Each,Else,ElseIf,Empty,End,Eqv,Erase,Error,Exit,Explicit,False,For,Function,Imp," _
& "In,Is,Loop,Mod,Next,Not,Nothing,Null,On,Option,Or,Private,Property,Public,Randomize,ReDim,Resume,Select,Set,Step," _
& "Sub,Then,To,True,Until,Wend,While,With,Xor,Anchor,Array,Asc,Atn,CBool,CByte,CCur,CDate,CDbl,Chr,CInt," _
& "CLng,Cos,CreateObject,CSng,CStr,DateAdd,DateDiff,DatePart,DateSerial,DateValue,Day,Dictionary,Document,Element,Err,Exp,FileSystemObject,Filter,Fix,Form," _
& "FormatCurrency,FormatDateTime,FormatNumber,FormatPercent,GetObject,Hex,History,Hour,IIf,InputBox,InStr,InstrRev,IsArray,IsDate,IsEmpty,IsNull,IsNumeric,IsObject,Join,LBound," _
& "LCase,Left,Len,Link,LoadPicture,Location,Log,LTrim,RTrim,Mid,Minute,Month,MonthName,MsgBox,Navigator,Now,Oct,Replace,Right,Rnd," _
& "Round,ScriptEngine,ScriptEngineBuildVersion,ScriptEngineMajorVersion,ScriptEngineMinorVersion,Second,Sgn,Sin,Space,Split," _
& "Sqr,StrComp,String,StrReverse,Tan,TextStream,TimeSerial,TimeValue,TypeName,UBound,UCase,VarType,Weekday,WeekDayName,Window,Year,Let,New,Static,Module," _
& "Variant,IsError,IsMissing,Me,Deftype,Like,Clear,Raise,CVErr,Collection,Remove,Item,DDB,SLN,SYD,FV,Rate,IRR,MIRR,NPer," _
& "IPmt,PPmt,NPV,GoSub,GoTo,Return,DoEvents,Stop,Choose,Switch,Get,ChDir,ChDrive,FileCopy,MkDir,RmDir,CurDir,FileDateTime,GetAttr,FileLen," _
& "SetAttr,Timer,Open,Close,Reset,Format,Print,PrintSpc,Tab,Width,EOF,FileAttr,FreeFile,Loc,LOF,Seek,Kill,Lock,Unlock,Input," _
& "InputLine,PrintPut,Write,CDec,CVar,Boolean,Double,Integer,Long,Single,Abs,Base,AppActivate,Shell,SendKeys,Beep,Environ,Command,MacID,MacScript," _
& "QBColor,RGB,DeleteSetting,GetSetting,GetAllSettings,SaveSetting,Val,StrConv,LSet,RSet,Compare,Enum,Declare,Alias,Lib,AddressOf,VarPtr,Any,Load,LoadResData," _
& "LoadResPicture,LoadResString,Access,Append,Binary,Output,Random,Read,Shared,As,If,ByRef,ByVal,Optional,Enum,Type"