The VB / ASP source code coloring

  Many such procedures online, but used练练"is the expression" good, and so they used to write this, and now only the code (functions, keywords, objects, string) coloring, the next step would like to join the fold effect function block (. NET code editor effect). 

  Demonstration effects code: (ChangeVBToColor function that is the key function) 
  ————————————————– ————————————————– ———– 
  <! DOCTYPE HTML PUBLIC "- / / W3C / / DTD HTML 4.01 Transitional / / EN" 
  "Http://www.w3.org/TR/html4/loose.dtd"> 
<html>
<head>
  <meta Http-equiv="Content-Type" content="text/html; charset=gb2312"> 
  <title> Untitled document </ title> 
  <style Type="text/css"> 
  <! – 
  Body ( 
  Font-family: "10 lines"; 
  Font-size: 12px; 
  Color: # 333333; 
  ) 
  . Text ( 
  Font-family: "10 lines"; 
  Font-size: 12px; 
  Border: 1px solid # 333333; 
  ) 
  Td ( 
  Font-family: "10 lines"; 
  Font-size: 12px; 
  ) 
–>
  </ Style> 
  </ Head> 

<body>
  <table Width="760" height="399" border="0" cellpadding="0" cellspacing="2"> 
<tr>
  <td Height="302" valign="top"> <form name="form1" method="post" action=""> 
  <div Align="center"> 
  <textarea Name="Content" cols="120" rows="25" class="Text" id="Content"> </ textarea> 
<br>
  <input Name="btnShow" type="button" class="Text" id="btnShow" value=" significant示" OnClick="GetHtmlContent()"> 
  </ Div> 
  </ Form> </ td> 
  </ Tr> 
<tr>
  <td Height="91"> <span id="sHtml"> </ span> </ td> 
  </ Tr> 
  </ Table> 
  <SCRIPT LANGUAGE="VBScript"> 
  Sub GetHtmlContent 
  'GGG form1.Content.value 
  Document.all.sHtml.innerHTML = ChangeVbToColor (HtmlEncode (form1.Content.value)) 
  End Sub 

  Function ChangeVbToColor (ByVal sText) 
  Dim re, Matches, i 
  Dim oneReg 
  Set re = new RegExp 
  Re.IgnoreCase = true 
  Re.Global = true 
  'Transfer function block 
  'Re.Pattern = "Function (\ w +) (\ ([^ \)] * \ ))?([^ End Function] *) End Function" 
  'SText = re.Replace (sText, "<font color=red> $ 1 </ font>") 
  'SText = re.Replace (sText, "<img src=http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif> $ 3") 
  'Alert sText 
  'Convert to retain the word [blue] 
  Re.Pattern = "(\ bAnd \ b | \ bByRef \ b | \ bByVal \ b | \ bCall \ b | \ bCase \ b | \ bClass \ b | \ bConst \ b | \ bDim \ b | \ bDo \ b | \ bEach \ b | \ bElse \ b | \ bElseIf \ b | \ bEmpty \ b | \ bEnd \ b | \ bEqv \ b | \ bErase \ b | \ bError \ b | \ bExit \ b | \ bExplicit \ b | \ bFalse \ b | \ bFor \ b | \ bFunction \ b | \ bGet \ b | \ bIf \ b | \ bImp \ b | \ bIn \ b | \ bIs \ b | \ bLet \ b | \ bLoop \ b | \ bMod \ b | \ bNext \ b | \ bNot \ b | \ bNothing \ b | \ bNull \ b | \ bOn \ b | \ bOption \ b | \ bOr \ b | \ bPrivate \ b | \ bProperty \ b | \ bPublic \ b | \ bRandomize \ b | \ bReDim \ b | \ bRem \ b | \ bResume \ b | \ bSelect \ b | \ bSet \ b | \ bStep \ b | \ bSub \ b | \ bThen \ b | \ bTo \ b | \ bTrue \ b | \ bUntil \ b | \ bWend \ b | \ bWhile \ b | \ bXor \ b) " 
  SText = re.Replace (sText, "<font color=blue> $ 1 </ font>") 
  'Conversion functions and objects [red] 
  Re.Pattern = "(\ bAnchor \ b | \ bArray \ b | \ bAsc \ b | \ bAtn \ b | \ bCBool \ b | \ bCByte \ b | \ bCCur \ b | \ bCDate \ b | \ bCDbl \ b | \ bChr \ b | \ bCInt \ b | \ bCLng \ b | \ bCos \ b | \ bCreateObject \ b | \ bCSng \ b | \ bCStr \ b | \ bDate \ b | \ bDateAdd \ b | \ bDateDiff \ b | \ bDatePart \ b | \ bDateSerial \ b | \ bDateValue \ b | \ bDay \ b | \ bDictionary \ b | \ bDocument \ b | \ bElement \ b | \ bErr \ b | \ bExp \ b | \ bFileSystemObject \ b | \ bFilter \ b | \ bFix \ b | \ bInt \ b | \ bForm \ b | \ bFormatCurrency \ b | \ bFormatDateTime \ b | \ bFormatNumber \ b | \ bFormatPercent \ b | \ bGetObject \ b | \ bHex \ b | \ bHistory \ b | \ bHour \ b | \ bInputBox \ b | \ bInStr \ b | \ bInstrRev \ b | \ bIsArray \ b | \ bIsDate \ b | \ bIsEmpty \ b | \ bIsNull \ b | \ bIsNumeric \ b | \ bIsObject \ b | \ bJoin \ b | \ bLBound \ b | \ bLCase \ b | \ bLeft \ b | \ bLen \ b | \ bLink \ b | \ bLoadPicture \ b | \ bLocation \ b | \ bLog \ b | \ bLTrim \ b | \ bRTrim \ b | \ bTrim \ b | \ bMid \ b | \ bMinute \ b | \ bMonth \ b | \ bMonthName \ b | \ bMsgBox \ b | \ bNavigator \ b | \ bNow \ b | \ bOct \ b | \ bReplace \ b | \ bRight \ b | \ bRnd \ b | \ bRound \ b | \ bScriptEngine \ b | \ bScriptEngineBuildVersion \ b | \ bScriptEngineMajorVersion \ b | \ bScriptEngineMinorVersion \ b | \ bSecond \ b | \ bSgn \ b | \ bSin \ b | \ bSpace \ b | \ bSplit \ b | \ bSqr \ b | \ bStrComp \ b | \ bString \ b | \ bStrReverse \ b | \ bTan \ b | \ bTime \ b | \ bTextStream \ b | \ bTimeSerial \ b | \ bTimeValue \ b | \ bTypeName \ b | \ bUBound \ b | \ bUCase \ b | \ bVarType \ b | \ bWeekday \ b | \ bWeekDayName \ b | \ bWindow \ b | \ bYear \ b) " 
  SText = re.Replace (sText, "<font color=red> $ 1 </ font>") 
  'Convert string [purple] 
  Re.Pattern ="(""[^""]*"")" 
  SText = re.Replace (sText, "<font color=#FF33FF> $ 1 </ font>") 
  SText = Replace (sText, CHR (34), "" ") 
  SText = Replace (sText, CHR (39), " '") 
  ChangeVbToColor = sText 
  End Function 

  Function HTMLEncode (fString) 
  If Not isnull (fString) Then 
  FString = replace (fString, "&", "&") 
  FString = replace (fString, ">", ">") 
  FString = replace (fString, "<", "<") 
  FString = replace (fString, CHR (32), "") 
  FString = replace (fString, CHR (9), "") 
  FString = Replace (fString, CHR (13), "") 
  FString = Replace (fString, CHR (10) & CHR (10), "</ P> <P>") 
  FString = Replace (fString, CHR (10), "<BR>") 
  HTMLEncode = fString 
Else
  HTMLEncode = "" 
  End If 
  End Function 
  Function GGG (ByVal sText) 
  Dim re, name, strTemplate, Matches, i 
  Dim oneReg 
  Set re = new RegExp 
  Re.IgnoreCase = true 
  Re.Global = true 
  '"<(.*)>.*< Re.Pattern = \ / \ 1> " 
  Re.Pattern = "Function (\ w +) (\ ([^ \)] * \ ))?(.[^( End Function)] *) End Function" 
  Set Matches = re.Execute (sText) 
  Alert sText 
  Alert Matches.Count 
  For i = 0 to Matches.Count-1 
  Alert Matches (i). SubMatches (0) & "<br>" 
Next
  End Function 
  </ SCRIPT> 
  </ Body> 
  </ Html> 

Bookmark it: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • Sphinn
  • del.icio.us
  • Google
  • DotNetKicks
  • DZone
  • Furl
  • Netvouz

Tags: , , ,

Releated Articles


0 Comments to “The VB / ASP source code coloring”

No Comments. Send your comment.

Leave a Reply

You must be logged in to post a comment.