vb调用函数

来源:百度知道 编辑:UC知道 时间:2024/07/02 04:56:30
Private Sub Command1_Click()
Dim a, b, c, d, e As Integer
a = Val(InputBox("请输入第1个数"))
b = Val(InputBox("请输入第2个数"))
c = Val(InputBox("请输入第3个数"))
d = Val(InputBox("请输入第4个数"))
e = Val(InputBox("请输入第5个数"))
MsgBox ("输入完成,请点击计算")
End Sub

Private Sub Command2_Click()
Dim x As Integer
x = a + b + c + d + e
Open "C:\Documents and Settings\All Users\桌面\计算结果.txt" For Output As #1
Write #1, x
Close #1
MsgBox ("计算完毕,请到桌面查看结果")
End Sub

如上 怎么些一个函数 才能调用输入的abcde啊?
我是新手 越详细越好 有加分

定义函数
private function He(byval a as integer,byval b as integer,byval c as integer,byval d as integer,byval e as integer) as integer
he=a+b+c+d+e
end function
用下列语句调用
x = he(a , b, c , d , e)

open "C:\Documents and Settings\All Users\桌面\计算结果.txt" for input as #1
do while not eof(1)
input #1, a(i)
i=i+1
loop
close #1

要哪个数就直接调用。这样可以吗?

使用input进行读入,就像你使用output一样。