×

VB.Net基本教程

VB.Net 环境设置VB.Net 程序结构VB.Net 基本语法VB.Net 数据类型VB.Net 变量VB.Net 常数和枚举VB.Net 修饰符VB.Net 声明VB.Net 指令VB.Net 运算符VB.Net 决策VB.Net 循环VB.Net 字符串VB.Net 日期和时间VB.Net 数组VB.Net 集合VB.Net 函数VB.Net Sub过程(子程序)VB.Net 类与对象VB.Net 异常处理VB.Net 文件处理VB.Net 基本控制VB.Net 对话框VB.Net 高级表单VB.Net 事件处理

VB.Net 高级教程

VB.Net 正则表达式VB.Net 数据库访问VB.Net Excel工作表VB.Net 发送邮件VB.Net XML处理VB.Net Web编程

VB.Net 有用的资源

VB.Net 有用资源

VB.Net 算术运算符


VB.Net  运算符VB.Net 运算符


下表显示了VB.Net支持的所有算术运算符。 假设变量A保持2,变量B保持7,则:

运算符 描述 示例
^ Raises one operand to the power of another
将一个操作数提升为另一个的权力
B^A will give 49
+ Adds two operands
添加两个操作数
A + B will give 9
- Subtracts second operand from the first
从第一个操作数中减去第二个操作数
A - B will give -5
* Multiplies both operands
将两个操作数相乘
A * B will give 14
/ Divides one operand by another and returns a floating point result
将一个操作数除以另一个操作数,并返回一个浮点结果
B / A will give 3.5
Divides one operand by another and returns an integer result
将一个操作数除以另一个操作数,并返回一个整数结果
B A will give 3
MOD Modulus Operator and remainder of after an integer division
模数运算符和整数除法后的余数
B MOD A will give 1

示例:

请尝试下面示例了解所有可用在 VB.Net 算术运算符
Module operators
   Sub Main()
      Dim a As Integer = 21
      Dim b As Integer = 10
      Dim p As Integer = 2
      Dim c As Integer
      Dim d As Single
      c = a + b
      Console.WriteLine("Line 1 - Value of c is {0}", c)
      c = a - b
      Console.WriteLine("Line 2 - Value of c is {0}", c)
      c = a * b
      Console.WriteLine("Line 3 - Value of c is {0}", c)
      d = a / b
      Console.WriteLine("Line 4 - Value of d is {0}", d)
      c = a  b
      Console.WriteLine("Line 5 - Value of c is {0}", c)
      c = a Mod b
      Console.WriteLine("Line 6 - Value of c is {0}", c)
      c = b ^ p
      Console.WriteLine("Line 7 - Value of c is {0}", c)
      Console.ReadLine()
   End Sub
End Module

当上述代码被编译和执行时,它产生以下结果:
Line 1 - Value of c is 31
Line 2 - Value of c is 11
Line 3 - Value of c is 210
Line 4 - Value of d is 2.1
Line 5 - Value of c is 2
Line 6 - Value of c is 1
Line 7 - Value of c is 100


VB.Net  运算符VB.Net 运算符


分类导航

关注微信下载离线手册

bootwiki移动版 bootwiki
(群号:472910771)