Visual Basic中除法运算的代码!!
来源:百度知道 编辑:UC知道 时间:2024/06/28 00:13:32
老师让写一个简单计算器~~~```
实现 加减乘除~~~
还要判断0不能为被除数~~~
“/”这个我知道~~~``
什么也不说!!
真是的!!
还有就是余数应该怎么球???
实现 加减乘除~~~
还要判断0不能为被除数~~~
“/”这个我知道~~~``
什么也不说!!
真是的!!
还有就是余数应该怎么球???
余数很好求,用Mod就可以了。
例:
Private Sub Command1_Click()
Print Val(Text1.Text) Mod Val(Text2.Text)
End Sub
Private Sub Form_Load()
Text1.Text = ""
Text2.Text = ""
End Sub
'注:Text1和Text2的KeyPress事件我没打,一定要输入数字,你自己编吧
Dim a as Single
Dim b as Single
Dim c as Single
a=16
b=9
If B<>0 Then
c = a / b
End If
余数用mod
/