不一样的,主要的关键字差不多,语法有一些有变化
台安网站建设公司创新互联,台安网站设计制作,有大型网站制作公司丰富经验。已为台安上千家提供企业网站建设服务。企业网站搭建\成都外贸网站建设公司要多少钱,请找那个售后服务好的台安做网站的公司定做!
vb.net与vb语法的一个很大不同——oop设计
例如
sMyString = Mid(sMyString,3,4)
现在,它可以被替换为:
sMyString = sMyString.substring(3,4)
你这是vb.net的代码,vb中不允许那么写:
Dim
strdx()
As
String
=
{"0",
"0",
"0"}
'定义个数组,从后面的值能看的出最大下标是2,也就是strdx(0),strdx(1)和strdx(2),3个的默认值都为0
Dim
calcount1
As
String
=
"0"
'定义个字符串变量
Dim
calcount2
As
String
=
"0"
Dim
strvalue
As
Boolean
=
False
'定义strvalue为bool值,改类型变量只有true和false
2种值
If
strdx(0)
=
"0"
Then
TextBox1.Text
=
strdx(0)
"."
这是字符串连接符号,和"+"的区别是,他把左右2边的内容直接连接的,而"+"可能会编程运算符,例如
2
3
=
"23"
而
2
+
3
=
5
ElseIf
strvalue
=
False
Then
strdx(0)
=
strdx(0)
"0"
TextBox1.Text
=
strdx(0)
"."
strvalue
=
True
Else
strdx(0)
=
strdx(0)
"0"
TextBox1.Text
=
strdx(0)
Select
Case
calcount1
'
这里开始是分支语句
Case
"+"
TextBox1.Text
=
Str(Val(strdx(1))
+
Val(strdx(0)))
比较长 不过支持全部的关键字 直接就可以用了 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 年 月 日/date/// Memo/// 练习正则表达式/// /Memo/// /summarypublic 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_MENT = @ font colr=# ;const string TAG_EMENT = @ /font ;
//
public CodeAnalysis(){//// TODO: 在此处添加构造函数逻辑//}
/// summary/// 处理VB NET代码 彩色化 /// /summary/// param name= Code 传入的Code/param/// returns处理过后的代码/returnspublic 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 };
////设定转换代码颜色//
lishixinzhi/Article/program/net/201311/14615