代码示例:
Sub
Dim NOSSPrefix As String
NOSSPrefix = Cells(1, 6).Value
NOSSSpecific(NOSSPrefixSpec)
End Sub
Function NOSSSpecific(NOSSPrefixSpec)
If NOSSPrefixSpec = "6" Or NOSSPrefixSpec = "17" Or NOSSPrefixSpec = "19" Then
NOSSPrefix = NOSSPrefixSpec
Else
NOSSPrefix = "999"
End If
End Function
尝试回归,设定,...... 只想将NOSSPrefix从函数返回到上面的例程。
答案 0 :(得分:3)
这样的事情:
Sub Main()
Dim NOSSPrefixSpec As String
NOSSPrefixSpec = "12"
Debug.Print NOSSSpecific(NOSSPrefixSpec) //Returns "999"
End Sub
Function NOSSSpecific(NOSSPrefixSpec As String) As String
If NOSSPrefixSpec = "6" Or NOSSPrefixSpec = "17" Or NOSSPrefixSpec = "19" Then
NOSSSpecific = NOSSPrefixSpec
Else
NOSSSpecific = "999"
End If
End Function
注意:
NOSSPrefix
。我将其更改为NOSSPrefixSpec
String
作为函数参数类型并返回值