最稳的pk10计划iphone 北京pk10计划手机软件 北京pk10数字的规律 超神手机版pk10软件 pk10北京赛车9码技巧 pk10四期倍投计划表 pk10极速赛车论坛 北京赛车冠军怎样选5码 北京赛车系统下载安装 pk10教程视频 北京pk10选号公式 北京赛车pk10赚钱技巧 北京赛车怎么提升概率 pk10技巧北京快三 北京pk10大小计划
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; 
}
}
}

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

pk10赛车冠军技巧
最稳的pk10计划iphone 北京pk10计划手机软件 北京pk10数字的规律 超神手机版pk10软件 pk10北京赛车9码技巧 pk10四期倍投计划表 pk10极速赛车论坛 北京赛车冠军怎样选5码 北京赛车系统下载安装 pk10教程视频 北京pk10选号公式 北京赛车pk10赚钱技巧 北京赛车怎么提升概率 pk10技巧北京快三 北京pk10大小计划
三国群英7怎么快速赚钱 彩狗街机捕鱼 重庆时时彩软件 北京pk 10 微信群内怎么样赚钱 短视频怎样在自媒体上赚钱 重庆时时彩龙虎正规吗 时时彩两星稳赚技巧 湖北11选5遗漏万能7码