首页 > 编程语言 > 详细

VBA_Excel_教程:过程,函数

时间:2016-12-03 12:36:05      阅读:109      评论:0      收藏:0      [点我收藏+]
Sub s1()

    Debug.Print "s1"
    调用过程:无括号,加call提升可读性
    s2
    Call s2
End Sub

Sub s2()
    Debug.Print "s2"
End Sub

函数当过程用完全没有问题

Function f1()
    Debug.Print "f1"
    f2
    Call f2
End Function

Function f2()
    Debug.Print "f2"
End Function

函数是可以有返回值的

Function f1()
    Debug.Print "f1"
    strRet = f2
    Debug.Print strRet
    strRet = f3
    Debug.Print strRet
    
End Function

Function f2() As String
    函数返回值用【函数名】表示
    f2 = "return f2"
End Function

Function f3() 加返回值类型声明更安全,提升可读性
    f3 = "return f3"
End Function

 

VBA_Excel_教程:过程,函数

原文:http://www.cnblogs.com/AndyHoo/p/6128232.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!