1. <wbr id="m8vu6"></wbr>

      <del id="m8vu6"><center id="m8vu6"><source id="m8vu6"></source></center></del>
        <p id="m8vu6"><sub id="m8vu6"></sub></p>

        VB.net 2010 視頻教程 VB.net 2010 視頻教程 VB.net 2010 視頻教程
        SQL Server 2008 視頻教程 c#入門經典教程 Visual Basic從門到精通視頻教程
        當前位置:
        首頁 > 編程開發 > VBnet >
        • vb.net教程之完整的VB.NET的語法解析程序

        • 2017-06-07 15:59 來源:未知
        作者: blood 
          比較長,不過支持全部的關鍵字,直接就可以用了。
        using System;
        using System.Text;
        using System.Text.RegularExpressions;

        namespace Com.OSLeague.Component
        {
        /// <summary>
        /// 語法分析器,將所有Code根據語法進行變色
        /// <list type="VB">支持VB.NET</list>
        /// <list type="CS">支持CS</list>
        /// <author>掉掉</author>
        /// <date>2002年5月14日</date>
        /// <Memo>
        /// 練習正則表達式
        /// </Memo>
        /// </summary>
        public class CodeAnalysis
        {

        //
        //定義HTML開始和結束的語句,用于語法變色
        //

        const string TAG_FNTRED = @"<font color=""red"">";
        const string TAG_FNTBLUE = @"<font color=""blue"">" ;
        const string TAG_FNTGRN = @"<font color=""green"">" ;
        const string TAG_FNTMRN = @"<font color=""maroon"">" ;
        const string TAG_FNTBLACK = @"<font color=""black"">" ;
        const string TAG_EFONT = @"</font>" ;
        const string TAG_SPNYELLOW = @"<span style=""background-color: yellow;"">";
        const string TAG_ESPAN = @"</span>";
        const string TAG_B = @"<b>";
        const string TAG_EB = @"</b>";
        const string TAG_COMMENT = @"<font colr=#008200>";
        const string TAG_ECOMMENT = @"</font>";

        //



        public CodeAnalysis()
        {
        //
        // TODO: 在此處添加構造函數邏輯
        //
        }



        /// <summary>
        /// 處理VB.NET代碼,彩色化..
        /// </summary>
        /// <param name="Code">傳入的Code</param>
        /// <returns>處理過后的代碼</returns>
        public string ParseVB(string Code)
        {
        //
        //定義VB.NET中關鍵字,將其存為數組
        //

        string[] VB_Keyword = new string[]
        {
        "AddHandler","AddressOf","AndAlso","Alias","And","Ansi","As","Assembly","Auto","Boolean",
        "ByRef","Byte","ByVal","Call","Case","Catch","CBool","CByte","CChar",
        "CDate","CDec","CDbl","Char","CInt","Class","CLng","CObj","Const",
        "CShort","CSng","CStr","CType","Date","Decimal","Declare","Default",
        "Delegate","Dim","DirectCast","Do","Double","Each","Else","ElseIf","End",
        "Enum","Erase","Error","Event","Exit","False",
        "Finally","For","Friend","Function","Get","GetType","GoTo","Handles","If",
        "Implements","Imports","In","Inherits","Integer","Interface",
        "Is","Let","Lib","Like","Long","Loop","Me","Mod","Module",
        "MustInherit","MustOverride","MyBase","MyClass","Namespace","New","Next","Not","Nothing",
        "NotInheritable","NotOverridable","Object","On","Option","Optional","Or","OrElse",
        "Overloads","Overridable","Overrides","ParamArray","Preserve","Private","Property","Protected","Public",
        "RaiseEvent","ReadOnly","ReDim","RemoveHandler","Resume","Return",
        "Select","Set","Shadows","Shared","Short","Single","Static","Step","Stop",
        "String","Structure","Sub","SyncLock","Then","Throw",
        "To","True","Try","TypeOf","Unicode","Until","Variant","When","While",
        "With","WithEvents","WriteOnly","Xor"
        };



        //
        //設定轉換代碼顏色
        //

        string ReplaceVBComment = TAG_COMMENT + "$1" + TAG_ECOMMENT;
        string ReplaceVBKeyword = TAG_FNTBLUE + "${char}" + TAG_EFONT;
        //開始轉換
        for (int i=0;i<VB_Keyword.Length;i++)
        {
        string TempDirectives = @"(?<char>(\s" + VB_Keyword[i] + "|" + VB_Keyword[i] + @"\s))";
        Code = Regex.Replace(Code,TempDirectives,ReplaceVBKeyword,RegexOptions.IgnoreCase);
        Code = Regex.Replace(Code,@"'(?<x>[^\r\n]*)",ReplaceVBComment);
        Code = Regex.Replace(Code,@"REM (?<x>[^\r\n]*)",ReplaceVBComment);
        }
        return Code; 
        }
        }
        }

        本欄文章均來自于互聯網,版權歸原作者和各發布網站所有,本站收集這些文章僅供學習參考之用。任何人都不能將這些文章用于商業或者其他目的。

        相關教程
        免费看成年人视频大全_免费看成年人视频在线观看