求VB题的答案,请高手指教~~
在文本框中输入除数和被除数,单击【执行除法运算】按钮时,在下面三个文本框里分别显示计算结果。界面如下:=======================除数:被除数:商(/)...
在文本框中输入除数和被除数,单击【执行除法运算】按钮时,在下面三个文本框里分别显示计算结果。
界面如下:
=======================
除数:
被除数:
商(/):
整数商(\):
余数商(Mod):
【执行除法运算】 展开
界面如下:
=======================
除数:
被除数:
商(/):
整数商(\):
余数商(Mod):
【执行除法运算】 展开
6个回答
展开全部
按照你的命名来做:
双击执行除法运算
Private Sub Command1_Click()
Text3.Text = Text1.Text / Text2.Text
Text4.Text = Text1.Text \ Text2.Text
Text5.Text = Text1.Text Mod Text2.Text
End Sub
就可以了
之前应该把所有text的text属性都清空
双击执行除法运算
Private Sub Command1_Click()
Text3.Text = Text1.Text / Text2.Text
Text4.Text = Text1.Text \ Text2.Text
Text5.Text = Text1.Text Mod Text2.Text
End Sub
就可以了
之前应该把所有text的text属性都清空
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
'text1为被除数 text2为除数
Private Sub Command1_Click() '执行除法运算
text3 = Val(trim(Text1.Text)) / Val(trim(Text2.Text)) '商
text4 = Val(trim(Text1.Text)) \ Val(trim(Text2.Text)) '整数商
text5 = Val(trim(Text1.Text)) Mod Val(trim(Text2.Text)) '求余
End Sub
Private Sub Command1_Click() '执行除法运算
text3 = Val(trim(Text1.Text)) / Val(trim(Text2.Text)) '商
text4 = Val(trim(Text1.Text)) \ Val(trim(Text2.Text)) '整数商
text5 = Val(trim(Text1.Text)) Mod Val(trim(Text2.Text)) '求余
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Private Sub Command1_Click()
If IsNumeric(Text1.Text) And IsNumeric(Text2.Text) Then
If Val(Text1.Text) Then
Text3.Text = Val(Text1.Text) / Val(Text2.Text)
Text4.Text = Fix(Val(Text1.Text) / Val(Text2.Text)) '或int()都会删除小数部份而返回剩下的整数
Text5.Text = Val(Text1.Text) Mod Val(Text2.Text)
Else
MsgBox "除数为零!"
End If
Else
MsgBox "被除数或除数输入错误!"
End If
End Sub
If IsNumeric(Text1.Text) And IsNumeric(Text2.Text) Then
If Val(Text1.Text) Then
Text3.Text = Val(Text1.Text) / Val(Text2.Text)
Text4.Text = Fix(Val(Text1.Text) / Val(Text2.Text)) '或int()都会删除小数部份而返回剩下的整数
Text5.Text = Val(Text1.Text) Mod Val(Text2.Text)
Else
MsgBox "除数为零!"
End If
Else
MsgBox "被除数或除数输入错误!"
End If
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
要准备5个文本,5个标签,一个按纽,注意被除数可以为0 但除数不能为0,代码如下
Option Explicit: Dim a As Long, b As Long, c As Long, d As Long
Private Sub Command1_Click()
a = Int(Text1.Text): b = Int(Text2.Text)
c = Int(Text1.Text): d = Int(Text2.Text)
If b <> 0 Then Text4.Text = a \ b
If b = 0 Then MsgBox "除数不能为0"
If Val(Text2.Text) <> 0 Then Text3.Text = Val(Text1.Text) / Val(Text2.Text)
If Val(Text2.Text) = 0 Then MsgBox "除数不能为0"
If d <> 0 Then Text5.Text = c Mod d
If d = 0 Then MsgBox "除数不能为0"
End Sub
Private Sub Form_Load()
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
Label1.Caption = "被除数:"
Label2.Caption = "除数:"
Label3.Caption = "商(/):"
Label4.Caption = "整数商(\):"
Label5.Caption = "余数商(Mod):"
Command1.Caption = "【执行除法运算】"
End Sub
Option Explicit: Dim a As Long, b As Long, c As Long, d As Long
Private Sub Command1_Click()
a = Int(Text1.Text): b = Int(Text2.Text)
c = Int(Text1.Text): d = Int(Text2.Text)
If b <> 0 Then Text4.Text = a \ b
If b = 0 Then MsgBox "除数不能为0"
If Val(Text2.Text) <> 0 Then Text3.Text = Val(Text1.Text) / Val(Text2.Text)
If Val(Text2.Text) = 0 Then MsgBox "除数不能为0"
If d <> 0 Then Text5.Text = c Mod d
If d = 0 Then MsgBox "除数不能为0"
End Sub
Private Sub Form_Load()
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
Label1.Caption = "被除数:"
Label2.Caption = "除数:"
Label3.Caption = "商(/):"
Label4.Caption = "整数商(\):"
Label5.Caption = "余数商(Mod):"
Command1.Caption = "【执行除法运算】"
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Private Sub Command1_Click()
Dim a As Integer, b As Integer, c As Double, d As Integer, e As Integer
a = Text1.Text
b = Text2.Text
c = a / b
d = a \ b
e = a Mod b
Text3.Text = c
Text4.Text = d
Text5.Text = e
End Sub
Dim a As Integer, b As Integer, c As Double, d As Integer, e As Integer
a = Text1.Text
b = Text2.Text
c = a / b
d = a \ b
e = a Mod b
Text3.Text = c
Text4.Text = d
Text5.Text = e
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询