自定一个public function(a,b,c)…………end function
text1=function(a1,b1,c1),调用成功
但把function 換成sub,其他不变,調用失敗,爲什麽??
还有,function和sub的参数传递数目是不是有区别或限制?

解决方案 »

  1.   

    function是自定义的函数~~
    sub是系统过程
      

  2.   

    Sub 不返回值
    Function 返回值
      

  3.   

    Sub 不返回值
    你的text1=sub(a1,b1,c1)怎么行得通啊!
      

  4.   

    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
      

  5.   

    Sub   不能有返回值  叫过程Function  可有返回值 可无返回值  叫函数 
    其他 相同