【问题标题】:What is the default return value of a VB6 function?VB6 函数的默认返回值是多少?
【发布时间】:2012-02-02 09:33:13
【问题描述】:

在处理一段旧代码时,我遇到了这样的事情:-

Public Function MyFunc (some parameters) As Single

    If some condition Then
        MyFunc = calculate some value
    Else
        MyFunc = MyFunc
    End If

End Function

我更希望能够规范该测试的第二阶段;如果some conditionfalse,我假设返回值是0.0 是正确的吗?

【问题讨论】:

    标签: vb6


    【解决方案1】:

    是的,对于具有已定义返回类型的函数,默认返回值是该类型的默认值(0 表示数字等),就像代码在顶部包含 Dim MyFunc as Single 一样。

    如果未指定类型且未隐式返回值,则返回 Empty 值。

    【讨论】:

    • “未指定类型”是 Variant 类型的隐式说明。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-02-22
    • 2012-08-03
    • 2016-10-28
    相关资源
    最近更新 更多