namespace Com OSLeague Component{/// <summary>/// 语法分析器 将所有Code根据语法进行变色/// <list type= VB >支持VB NET</list>/// <list type= CS >支持CS</list>/// <author>掉掉</author>/// <date>年 月 日锋亩</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_MENT = @ <font colr=# >const string TAG_EMENT = @ </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 }
////设定转换代码颜色//
lishixinzhi/Article/program/net/201311/14615分类: 电脑/网络 >>程序设计 >>其他编程语言
问题旁帆描述:
Private Sub Command1_Click()
s = 0
For i = 1 To 15
x = 2 * i - 1
If x Mod 3 = 0 Then s = s + 1
Next i
Label1.Caption = s
End Sub
以上是什么意思,最好解释清楚点!还有我要用VB做加法减法运算怎么做,把程序告诉我建一个Command1按钮改为相加,然后建立两个TEXTBOX之后在这两个文本框中输入数字,按相加按钮,答案显示在LABEL中
(答的对加50-100积分)
解析:
Private Sub Command1_Click() '按钮点击时间
s = 0 '把S初运此雹始为0 也就是设S=0
For i = 1 To 15 '使i的值从1到15递增,i每改变1次就执行下面两行一次
x = 2 * i - 1 '求X的值
If x Mod 3 = 0 Then s = s + 1 '如果X是3的倍数,那么S=S+1,即增加1
Next i
Label1.Caption = s '把S写在标签里面
End Sub
总体意思是 当I=1,2,3,。。。15时 记录2*I-1 的值为3的倍数的 个数
相加的代码
Private Sub Command1_Click()
Label1.Caption = Val(Text1.text) + Val(Text2.text)
End Sub
就可以扒简了,当然 - * / 和+的道理一样,改一下符号就可以了
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)