function 返回值 Private Function add(a As Integer, b As Integer, c As Integer) As Integer Dim addSum As Integer addSum = a + b + c add = addSum End FunctionPrivate Sub Command1_Click() Me.Print add(1, 2, 3) End Sub sub 只執行一段程序,不返回值,要想不出錯。Dim addSum As Integer Private Sub add(a As Integer, b As Integer, c As Integer) 'As Integer addSum = a + b + c End SubPrivate Sub Command1_Click() Call add(1, 2, 3) Me.Print addSum End Sub
sub是系统过程
Function 返回值
你的text1=sub(a1,b1,c1)怎么行得通啊!
Private Function add(a As Integer, b As Integer, c As Integer) As Integer
Dim addSum As Integer
addSum = a + b + c
add = addSum
End FunctionPrivate Sub Command1_Click()
Me.Print add(1, 2, 3)
End Sub
sub 只執行一段程序,不返回值,要想不出錯。Dim addSum As Integer
Private Sub add(a As Integer, b As Integer, c As Integer) 'As Integer
addSum = a + b + c
End SubPrivate Sub Command1_Click()
Call add(1, 2, 3)
Me.Print addSum
End Sub
其他 相同