Visual Basic 中怎么让两个文本框中的变量相加,然后把结果在第三个文本框里边输出?
小弟是菜鸟,刚刚接触VB,望高人指点。。。PrivateSubCommand1_Click()DimsumAsDoubleDimaAsIntegerDimbAsInteg...
小弟是菜鸟,刚刚接触VB,望高人指点。。。
Private Sub Command1_Click()
Dim sum As Double
Dim a As Integer
Dim b As Integer
a = Text1.Text
b = Text2.Text
sum = Addition(Text1.Text, Text2.Text)
Text3.Text = sum
Text3.Refresh
End Sub
这是我写的代码,但是它说sum变量中Addition那一项“子程序或函数为定义”,肿么回事?求救
解决了以后有高分!谢谢! 展开
Private Sub Command1_Click()
Dim sum As Double
Dim a As Integer
Dim b As Integer
a = Text1.Text
b = Text2.Text
sum = Addition(Text1.Text, Text2.Text)
Text3.Text = sum
Text3.Refresh
End Sub
这是我写的代码,但是它说sum变量中Addition那一项“子程序或函数为定义”,肿么回事?求救
解决了以后有高分!谢谢! 展开
5个回答
展开全部
Private Sub Command1_Click()
Dim sum As Double
Dim a As Integer
Dim b As Integer
a = Text1.Text
b = Text2.Text
sum = a+b '把这里改了 Addition(Text1.Text, Text2.Text)
Text3.Text = sum
Text3.Refresh
End Sub
或是你的代码不改动,加一个方法
private function Addition(a as integer,b as integer)
Addition=a+b
end sub
Dim sum As Double
Dim a As Integer
Dim b As Integer
a = Text1.Text
b = Text2.Text
sum = a+b '把这里改了 Addition(Text1.Text, Text2.Text)
Text3.Text = sum
Text3.Refresh
End Sub
或是你的代码不改动,加一个方法
private function Addition(a as integer,b as integer)
Addition=a+b
end sub
展开全部
sum = Addition(Text1.Text, Text2.Text)
改为 sum = val(a)+val(b)
改为 sum = val(a)+val(b)
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
sum = Addition(Text1.Text, Text2.Text)
改为 sum = a+b
改为 sum = a+b
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Private Sub Command1_Click()
Dim sum As Double
Dim a As Integer
Dim b As Integer
a = cint(Text1.Text)
b = cint(Text2.Text)
sum = Addition(a, b)
Text3.Text = cstr(sum)
Text3.Refresh
End Sub
public function Addition(byval x as integer,byval y as integer) as Double
return cdbl(x+Y)
end function
Dim sum As Double
Dim a As Integer
Dim b As Integer
a = cint(Text1.Text)
b = cint(Text2.Text)
sum = Addition(a, b)
Text3.Text = cstr(sum)
Text3.Refresh
End Sub
public function Addition(byval x as integer,byval y as integer) as Double
return cdbl(x+Y)
end function
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
直接 a+b
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |