How can I pass uniqueId and uniqueId from sub run to Sub DisplayCustomError. I tried to pass through DisplayCustomError but it's giving "Cannot use parentheses when calling a Sub".
Expected result: uniqueId and uniqueId should go to Sub DisplayCustomError to create a json object.
sub run
On Error Resume Next
wrapper.getVariable( "IRR" ).value = excel.range( "'Cases'!$H$783" )
Dim uniqueId , uniqueId , errorMessage
If Err.Number <> 0 And excel.range( "'Cases'!$H$783" ) = "" Then
errorCode = "MC2006"
uniqueId = "12"
errorMessage= "Error while executing EVMLite.
DisplayCustomError(errorMessage)
On Error Goto 0
Call Err.Raise(vbObjectError + 10, "EVM Failed to execute. ", errorMessage)
End If
end sub
Sub DisplayCustomError(errorMessage)
If Err.Number <> 0 Then
Dim objHTTP, URL, json, uniqueId, networkInfo, jobId
Set objHTTP = CreateObject("MSXML2.ServerXMLHTTP")
URL = "http://10.93.24.223:9005/vpp/logerror"
objHTTP.Open "POST", URL, False
objHTTP.SetRequestHeader "Content-Type", "application/json"
json = "{""jobId"": """& jobId &""", ""uniqueId"": """& uniqueId &""", ""errorCode"": """& errorCode &""", ""errorMessage"": """& errorMessage &"""}"
objHTTP.send (json)
End If
end sub
Change the
Callline from:To:
Edit 1: to pass multiple parameters:
First, you need to re-define your
Sub:Then, when you call it, make sure you pass the correct number and type of parameters:
B.T.W you can pass the parametes with differnet names and it will still work. For example:
And then
Edit 2: Full code edited (relevant parts)