vb.net加减运算 vb60加减乘除代码

VB.NET怎么位运算?

注意只能对整型执行按位运算。浮点值必须转换为整型后,才能执行按位运算。按位运算采用二进制(以 2 为基)形式计算两个整数值。它们比较对应位置上的位,然后基于比较的结果赋值。下面的示例演示了 And 运算符。复制Dim x As Integerx = 3 And 5 前面的示例将 x 的值设置为 1。发生这种情况的原因如下:这些值以二进制形式处理:二进制格式的 3 为 011二进制格式的 5 为 101And 运算符比较这些二进制表示方式,一次比较一个二进制位置(位)。如果给定位置的两个位都为 1,则将 1 放在结果中的该位置。如果任何一个位是 0,则将 0 放在结果中的该位置。在前面的示例中,按如下所示计算结果:011(二进制格式的 3)101(二进制格式的 5)001(二进制格式的计算结果)计算结果以十进制形式处理。值 001 是 1 的二进制表示形式,因此 x = 1。除了在任何一个比较位是 1 或两个比较位都是 1 的情况下将 1 赋予结果位以外,按位 Or 运算与此类似。Xor 在比较的位正好只有一个是 1(而不是两者都是 1)时将 1 赋给结果位。Not 采用单个操作数并反转所有位(包括符号位),然后将该值赋予结果。这意味着,对于有符号正数,Not 始终返回负值,而对于负数,Not 始终返回正值或零。AndAlso 和OrElse 运算符不支持按位运算。 追问: 好复杂啊...还是不会,还有整数怎么转换为二进制数? 回答: 为什么一定要用位运算呢,你那个乘法只能通过左移操作符“ ”来进行,而左移一次代表乘以2,要是乘以一个小数,就必须先化成2的n次方,不够再用加减法调整,很麻烦啊,没必要用位运算啊。。。 追问: 因为我要进行大量的运算,但速度要快,所有用位运算...我也不想啊.. 回答: 那就不该用VB 啊,c/c++在执行效率上是没话说的。 追问: 问题就是不会嘛... 回答: 那你上csdn上发帖效果应该不错 追问: CSDN发了,我发在高性能运算,没人... 回答: 耐心一些,或者你应该发到VB.NET论坛那里。。。 追问: 额..只能这样了... 提问者 的感言: 太复杂了..算了 2010-11-08

临夏网站建设公司创新互联建站,临夏网站设计制作,有大型网站制作公司丰富经验。已为临夏近千家提供企业网站建设服务。企业网站搭建\外贸营销网站建设要多少钱,请找那个售后服务好的临夏做网站的公司定做!

VB.net作业,用VB做一个简单的计算器.

我用VB做的你看能不能用

Public b

Public c

Public d

Public e

Public f

Private Sub Command14_Click()

d = ""

If Text1.Text = "+" Or Text1.Text = "-" Or Text1.Text = "*" Or Text1.Text = "/" Then Exit Sub

'c = Text1.Text

If b = "" Then Exit Sub

If e = "+" Then

d = f + b

Else

If e = "-" Then

d = f - b

Else

If e = "*" Then

d = f * b

Else

If e = "/" Then

If b = 0 Then

MsgBox "被除数不能为零!"

Exit Sub

End If

d = f / b

Else

MsgBox "错误操作!"

End If

End If

End If

End If

Text1.Text = d

b = ""

c = ""

e = ""

End Sub

Private Sub Command15_Click()

Text1.Text = ""

b = ""

c = ""

d = ""

e = ""

f = ""

End Sub

Private Sub Form_Load()

Text1.Text = ""

End Sub

Private Sub Command1_Click()

'判断开头有运算符就清零

If Text1.Text = "+" Or Text1.Text = "-" Or Text1.Text = "*" Or Text1.Text = "/" Then Text1.Text = ""

'判断开头有0就禁止输入数字

If Text1.Text = "0" Then

Else

a = 1

'发现运算结果就清零

If d "" Then Text1.Text = "": d = ""

Text1.Text = Text1.Text a

End If

b = Text1.Text '得到当前操作数

End Sub

Private Sub Command2_Click()

If Text1.Text = "+" Or Text1.Text = "-" Or Text1.Text = "*" Or Text1.Text = "/" Then Text1.Text = ""

If Text1.Text = "0" Then

Else

a = 2

If d "" Then Text1.Text = "": d = ""

Text1.Text = Text1.Text a

End If

b = Text1.Text

End Sub

Private Sub Command3_Click()

If Text1.Text = "+" Or Text1.Text = "-" Or Text1.Text = "*" Or Text1.Text = "/" Then Text1.Text = ""

If Text1.Text = "0" Then

Else

a = 3

If d "" Then Text1.Text = "": d = ""

Text1.Text = Text1.Text a

End If

b = Text1.Text

End Sub

Private Sub Command4_Click()

If Text1.Text = "+" Or Text1.Text = "-" Or Text1.Text = "*" Or Text1.Text = "/" Then Text1.Text = ""

If Text1.Text = "0" Then

Else

a = 4

If d "" Then Text1.Text = "": d = ""

Text1.Text = Text1.Text a

End If

b = Text1.Text

End Sub

Private Sub Command5_Click()

If Text1.Text = "+" Or Text1.Text = "-" Or Text1.Text = "*" Or Text1.Text = "/" Then Text1.Text = ""

If Text1.Text = "0" Then

Else

a = 5

If d "" Then Text1.Text = "": d = ""

Text1.Text = Text1.Text a

End If

b = Text1.Text

End Sub

Private Sub Command6_Click()

If Text1.Text = "+" Or Text1.Text = "-" Or Text1.Text = "*" Or Text1.Text = "/" Then Text1.Text = ""

If Text1.Text = "0" Then

Else

a = 6

If d "" Then Text1.Text = "": d = ""

Text1.Text = Text1.Text a

End If

b = Text1.Text

End Sub

Private Sub Command7_Click()

If Text1.Text = "+" Or Text1.Text = "-" Or Text1.Text = "*" Or Text1.Text = "/" Then Text1.Text = ""

If Text1.Text = "0" Then

Else

a = 7

If d "" Then Text1.Text = "": d = ""

Text1.Text = Text1.Text a

End If

b = Text1.Text

End Sub

Private Sub Command8_Click()

If Text1.Text = "+" Or Text1.Text = "-" Or Text1.Text = "*" Or Text1.Text = "/" Then Text1.Text = ""

If Text1.Text = "0" Then

Else

a = 8

If d "" Then Text1.Text = "": d = ""

Text1.Text = Text1.Text a

End If

b = Text1.Text

End Sub

Private Sub Command9_Click()

If Text1.Text = "+" Or Text1.Text = "-" Or Text1.Text = "*" Or Text1.Text = "/" Then Text1.Text = ""

If Text1.Text = "0" Then

Else

a = 9

If d "" Then Text1.Text = "": d = ""

Text1.Text = Text1.Text a

End If

b = Text1.Text

End Sub

Private Sub Command10_Click()

If b = "" Then Exit Sub

a = "+"

e = "+"

f = b

Text1.Text = ""

Text1.Text = Text1.Text a

End Sub

Private Sub Command11_Click()

If b = "" Then Exit Sub

f = b

a = "-"

e = "-"

Text1.Text = ""

Text1.Text = Text1.Text a

End Sub

Private Sub Command12_Click()

If b = "" Then Exit Sub

a = "*"

e = "*"

f = b

Text1.Text = ""

Text1.Text = Text1.Text a

End Sub

Private Sub Command13_Click()

If b = "" Then Exit Sub

a = "/"

e = "/"

f = b '把操作数1提取出来

Text1.Text = ""

Text1.Text = Text1.Text a

End Sub

Private Sub Command16_Click()

'判断有运算符就清零

If Text1.Text = "+" Or Text1.Text = "-" Or Text1.Text = "*" Or Text1.Text = "/" Then Text1.Text = ""

'判断有零和空值就禁止输入0

'发现运算结果就清零

If d "" Then Text1.Text = "": d = ""

If Text1.Text = "0" Then

Else

a = 0

If d "" Then Text1.Text = "": d = ""

Text1.Text = Text1.Text a

b = Text1.Text

End If

End Sub

用vb设计一个计算器,里面的加减乘除按键的代码怎么写

简单点的:

dim 上一个数 as double

dim 下一个数 as double

dim 结果 as double

dim 操作 as string

private sub 加减乘除(byval sender as object, byval e as eventargs) handles 加.click, 减.click, 乘.click, 除.click

上一个数 = cdbl(输入框.text) ' 存储当前输入的数值

输入框.text = "" ' 等待下一个数值

select case sender.text ' 根据按下的按钮的文本属性确定你要做什么,这里可以用加减乘除号代替

case "加"

操作 = "加"

case "减"

操作 = "减"

case "乘"

操作 = "乘"

case "除"

操作 = "除"

end select

end sub

private sub 计算(byval sender as object, byval e as eventargs) handles 等号.click

下一个数 = 输入框.text

输入框.text = ”“

select case 操作

case "加"

结果 = 上一个数 + 下一个数

case "减"

结果 = 上一个数 - 下一个数

case "乘"

结果 = 上一个数 * 下一个数

case "除"

结果 = 上一个数 / 下一个数

end select

输入框.text = cstr(结果)

上一个数 = 结果

end sub

.NET 的哈,我没有 .NET 现在,不知道行不行


文章题目:vb.net加减运算 vb60加减乘除代码
当前地址:http://ybzwz.com/article/dogjhee.html