W3Cschool
恭喜您成為首批注冊(cè)用戶
獲得88經(jīng)驗(yàn)值獎(jiǎng)勵(lì)
下表顯示了VB.Net支持的所有算術(shù)運(yùn)算符。 假設(shè)變量A為2,變量B為7,則:
運(yùn)算符 | 描述 | 示例 |
---|---|---|
^ | 將一個(gè)操作數(shù)作為另一個(gè)操作數(shù)的指數(shù)進(jìn)行求冪運(yùn)算 | B^A 的結(jié)果是 49 |
+ | 兩個(gè)操作數(shù)相加 | A + B的結(jié)果是 9 |
- | 求第一個(gè)操作數(shù)減去第二個(gè)操作數(shù)的差 | A - B 的結(jié)果為 -5 |
* | 將兩個(gè)操作數(shù)相乘 | A * B 的結(jié)果為 14 |
/ | 求一個(gè)操作數(shù)除以另一個(gè)操作數(shù),并返回一個(gè)浮點(diǎn)結(jié)果 | B / A 的結(jié)果為 3.5 |
\ | 將一個(gè)操作數(shù)除以另一個(gè)操作數(shù),并返回一個(gè)整數(shù)結(jié)果(整除) | B \ A 的結(jié)果為 3 |
MOD | 模數(shù)運(yùn)算符和整數(shù)除法后的余數(shù)(取模) | B MOD A 的結(jié)果為 1 |
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
Copyright©2021 w3cschool編程獅|閩ICP備15016281號(hào)-3|閩公網(wǎng)安備35020302033924號(hào)
違法和不良信息舉報(bào)電話:173-0602-2364|舉報(bào)郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號(hào)
聯(lián)系方式:
更多建議: