如何使用Variant结果

时间:2015-09-14 07:33:08

标签: excel vba excel-vba

以下功能是Excel插件的一部分,用于将订单发送给代理。我相信无法访问加载项的内部工作方式。

当公式和参数输入电子表格单元格并执行(即发送订单)时,单元格的内容将被Variant类型的变量替换(例如“Formula sent”,“WORKING”,并且可能其他可能性。)

当函数的响应为“Variant”时,如何以编程方式最佳地分析输出?另外,如何防止结果更换配方?

Function orderSend(Optional account As String = vbNullString, Optional symbol As String = vbNullString, Optional side As String = vbNullString, Optional price As Currency = 0, Optional orderQty As Currency = 0, Optional orderType As String = vbNullString, Optional timeInForce As String = vbNullString, Optional expiryTime As String = vbNullString, Optional stopPrice As Currency = 0) As Variant
    ' Really Optional: price expiryTime stopPrice
    On Error GoTo ErrorHandler
        orderSend = tradingAddInFunctions.orderSend(Application.Caller, account, symbol, side, price, orderQty, orderType, timeInForce, expiryTime, stopPrice)
        Exit Function
ErrorHandler:
    orderSend = Err.Source & ": " & Err.Description
End Function

0 个答案:

没有答案