당신은 당신의 cStatus
함수의 반환 값을 할당되지 않으므로 라인 checkStatus = cStatus(10, "B_E")
는 수신 알고하지 않습니다. 당신이 값을 돌려 줄 필요가없는 경우
' Define a return type for the function (I used string).
Function cStatus(cValue, mName) As String
' Wrapping True and False in quotes since you are passing a string.
' If this is supposed to be a boolean, then type the parameter (see below).
If mName = "True" Then
rTotal = rTotal + cValue
ElseIf mName = "False" Then
rTotal = rTotal - cValue
End If
' Assign a return value.
cStatus = "the value"
End Function
다른 방법으로, 당신은 cStatus
Sub
을 만들 수 있습니다
Sub cStatus(cValue, mName)
If mName = "True" Then
rTotal = rTotal + cValue
ElseIf mName = "False" Then
rTotal = rTotal - cValue
End If
End Function
Private Sub BE_Click()
' No "checkStatus" variable.
cStatus 10, "B_E"
End Sub
보조 노트로
, 당신의 매개 변수 중 어느 것도 입력하지 않습니다를, 그래서 그들은 것이다 모두 Variant
이 으로, (ByRef
)으로 전달됩니다. 이것이 의도 된 것인지 확신 할 수 없지만 대부분의 시간에 관계없이 값을 전달하려는 경우 관계없이 입력하는 것이 좋습니다 (ByVal
). 예를 들어
:
Function cStatus(ByVal cValue As Integer, ByVal mName As Boolean) As String