Public function pagelist() 
if a=5 then 
b=10 
else 
b=15 
End Function 
问: 
我使用什么方法可以取到上面的function 中的b的返回值呢? 
我在外面要使用function 中的返回值! 
我改如何使用呢? 是一个很低级的问题,还请大人们不要见笑啊!

解决方案 »

  1.   

    Public function pagelist() as long
    if a=5 then 
      b=10 
    else 
      b=15 
    end if
    pagelist=b '加上一句返回 b 的值.
    End Function 
    另一函数中:private sub AA()
      msgbox pagelist
    end Sub
      

  2.   


    '或者可以用下面的方法
    private sub pagelist(byref b as Integer)
        if a=5 then 
            b=10 
        else 
            b=15
        end if
    end sub'调用pagelist的函数
    private sub aa()
        dim nNum as integer
        
        pagelist(nNum)
        'nNum已经取到返回值了
    end sub
      

  3.   

    Public function pagelist() 
    if a=5 then 
    b=10 
    else 
    b=15 
    pagelist=b '加这一行就行了
    End Function 
      

  4.   

    提示的是:Public function pagelist() as long 
    出错
      

  5.   

    运行的时候 提示
    private sub pagelist(byref b as Integer)缺少“)”
      

  6.   

    不用声明的,VBS里不用声明函数返回类型,完整格式大概这样子就行了Function pagelist() 
     Dim a,b
     If a=5 then 
        b=10 
     Else 
        b=15
     End If 
     pagelist=b 
    End Function 
      

  7.   

    Public function pagelist()
    if a=5 then 
      b=10 
    else 
      b=15 
    end if 
    pagelist=b '加上一句返回 b 的值. 
    End Function 这样看行不?
      

  8.   


    Private Sub pagelist(ByRef b As Integer)
        Dim a As Integer
        a = 5
        If a = 5 Then
            b = 10
        Else
            b = 15
        End If
    End Sub'调用pagelist的函数
    Private Sub aa()
        Dim nNum As Integer
        pagelist nNum
        'nNum已经取到返回值了
        Text1.Text = nNum
    End SubPrivate Sub Form_Load()
        aa
    End Sub这次肯定可以了,我机器上试过了