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
sum = Addition(Text1.Text, Text2.Text)
改为 sum = val(a)+val(b)
sum = Addition(Text1.Text, Text2.Text)
改为 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
直接 a+b