应该定义为double或者single,string类好像不能进行运算。我简单说一下控制台的方法,你要一次性输入和差积商,首先声明两个变量用来储存两个数,然后用算法一次性输出结果就ok。
在嵊州等地区,都构建了全面的区域性战略布局,加强发展的系统性、市场前瞻性、产品创新能力,以专注、极致的服务理念,为客户提供成都网站设计、成都网站建设、外贸网站建设 网站设计制作按需搭建网站,公司网站建设,企业网站建设,成都品牌网站建设,全网营销推广,成都外贸网站制作,嵊州网站建设费用合理。
Sub Main()
Dim FN As Single
Dim SN As Single
Dim ResultNum As Single
Console.WriteLine("请输入第一个数") : FN = Console.ReadLine
Console.WriteLine("请输入第二个数") : SN = Console.ReadLine
ResultNum = FN + SN
Console.WriteLine("它们的和: " ResultNum)
ResultNum = FN - SN
Console.WriteLine("它们的差: " ResultNum)
ResultNum = FN * SN
Console.WriteLine("它们的积: " ResultNum)
ResultNum = FN / SN
Console.WriteLine("它们的商: " ResultNum)
Console.ReadLine()
End Sub
比较长 不过支持全部的关键字 直接就可以用了 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
调用api
在Visual Baisc.net中的声明:
Declare Sub mouse_event Lib "user32" (ByVal dwFlags As Long, ByVal dx As Long, ByVal dy As Long, ByVal cButtons As Long, ByVal dwExtraInfo As Long)
Public Const MOUSEEVENTF_LEFTDOWN = H2 '模拟鼠标左键按下
Public Const MOUSEEVENTF_LEFTUP = H4 ’模拟鼠标左键释放
Public Const MOUSEEVENTF_MIDDLEDOWN = H20 '模拟鼠标中间键按下
Public Const MOUSEEVENTF_MIDDLEUP = H40 '模拟鼠标中间键释放
Public Const MOUSEEVENTF_RIGHTDOWN = H8 '模拟鼠标右键按下
Public Const MOUSEEVENTF_RIGHTUP = H10 '模拟鼠标右键释放
Public Const MOUSEEVENTF_MOVE = H1 '模拟鼠标指针移动
例:
mouse_event MOUSEEVENTF_LEFTDOWN,10,10,0,0
'在(10,10)模拟鼠标左键按下
可以的,把项目的类型设成类库,将所有的函数用Public修饰附封装在类里面,生成dll文件。这样别人就可以在别人项目属性的引用页里面添加对你的dll文件的引用,然后导入命名空间,直接使用了。
比如说,在一个项目里:
NameSpace Controller
Public Class ControlMachine
Public Sub Boot()
End Sub
Public Sub Shutdown()
End Sub
End Class
End NameSpace
进入另一个项目的项目属性,进入引用页,添加到那个dll文件的引用。在代码中:
Imports Controller '加在代码文档的最顶端
使用:
Dim controller As New ControlMachine
controller.Boot()
controller.Shutdown()
希望你能了解,不懂再追问