VB计算问题有公式:a+b=c,要求输入任意两个值,能求出第三个值.输入框中要求只能输入数字、小数点、负号.请大侠帮助…
来源:学生作业帮 编辑:作业帮 分类:综合作业 时间:2024/07/16 19:50:45
VB计算问题
有公式:a+b=c,要求输入任意两个值,能求出第三个值.输入框中要求只能输入数字、小数点、负号.请大侠帮助……
有公式:a+b=c,要求输入任意两个值,能求出第三个值.输入框中要求只能输入数字、小数点、负号.请大侠帮助……
Private Sub Command1_Click()
If Not IsNumeric(Trim(Text1.Text)) Then
MsgBox "A不是数字"
Text1.SetFocus
Exit Sub
End If
If Not IsNumeric(Trim(Text2.Text)) Then
MsgBox "B不是数字"
Text2.SetFocus
Exit Sub
End If
Text3.Text = Val(Text1.Text) + Val(Text2.Text)
End Sub
再问: 感谢你的回复,但是以上代码只能实现a、b求和功能,如果在b、c中输入数字,无法求得a的值啊!
再答: Private Sub Command1_Click() If IsNumeric(Trim(Text1.Text)) and IsNumeric(Trim(Text2.Text)) Then Text3.Text = Val(Text1.Text) + Val(Text2.Text) Elseif IsNumeric(Trim(Text1.Text)) and IsNumeric(Trim(Text3.Text)) Then Text2.Text = Val(Text3.Text) - Val(Text1.Text) Elseif IsNumeric(Trim(Text2.Text)) and IsNumeric(Trim(Text3.Text)) Then Text1.Text = Val(Text3.Text) - Val(Text2.Text) Else Msgbox "至少输入两个数值!" End If End Sub
If Not IsNumeric(Trim(Text1.Text)) Then
MsgBox "A不是数字"
Text1.SetFocus
Exit Sub
End If
If Not IsNumeric(Trim(Text2.Text)) Then
MsgBox "B不是数字"
Text2.SetFocus
Exit Sub
End If
Text3.Text = Val(Text1.Text) + Val(Text2.Text)
End Sub
再问: 感谢你的回复,但是以上代码只能实现a、b求和功能,如果在b、c中输入数字,无法求得a的值啊!
再答: Private Sub Command1_Click() If IsNumeric(Trim(Text1.Text)) and IsNumeric(Trim(Text2.Text)) Then Text3.Text = Val(Text1.Text) + Val(Text2.Text) Elseif IsNumeric(Trim(Text1.Text)) and IsNumeric(Trim(Text3.Text)) Then Text2.Text = Val(Text3.Text) - Val(Text1.Text) Elseif IsNumeric(Trim(Text2.Text)) and IsNumeric(Trim(Text3.Text)) Then Text1.Text = Val(Text3.Text) - Val(Text2.Text) Else Msgbox "至少输入两个数值!" End If End Sub
VB计算问题有公式:a+b=c,要求输入任意两个值,能求出第三个值.输入框中要求只能输入数字、小数点、负号.请大侠帮助…
制作一个能进行四则运算的计算器?要求有0-9数字输入和小数点计算.
用C语言写一个很简单的程序,输入两个整数a,b,要求输入a-b的值,例如:输入7 4,输出3
基础c语言问题:要求输入任意单词,输出单词的每个字母后的第三个字母.例如输入yeah,则输出bhdk
VB中输入方程ax2+bx+c=0的三个系数a、b、c(设a不等于零),求方程的根(要求输出时保留小数点两位).
vf计算最大值的问题clearinput "请输入第一个数字:" to a input "请输入第二个数字:" to b
VB中有A.B两个框,在A.B中分别输入数字a.b,先用一个函数得出a到b之间的偶数判定
1)编写一个C语言程序,输入a、b、c 3个值,输入其中最大者,要求在子函数里面比较数大
C语言的一道题目.有输入语句scanf(“a=%d,b=%d”,&i,&j);要求输入10和20,并且:① 写出输入时的
c语言:计算A+B 输入 输入数据有多组.每组一行,为两个整数A,B.输入以0 0结束.输出 输出A+B的值
C语言编程问题 编程任意输入两个实数a和b,计算下面函数的值,并输出y值. a-b a>b y= a/b a
在VB中输入依次输入a,b,c=inputbox(prompt,tittle),print a+b+c,当输入1,2,3