我有一个 RTD 服务器,用于向 Excel 发送数据和从 Excel 发送数据。我试图通过在 Excel 的 VBA 的模块中构建一些简单的函数来让用户更轻松,以允许他们在不知道整个后端的情况下获取数据。
Function parseData(ByVal arrayData As String) As Variant
parseData = Evaluate(arrayData)
End Function
Function getQuote(ByVal ticker As String) As String
getQuote = parseData(Application.RTD("rTech.Quotes", , ticker))
End Function
Function getBidSize(ByVal ticker As String) As String
getBidSize = Application.RTD("rTech.Quotes", , ticker, "bidsize")
End Function
Function getBidPrice(ByVal ticker As String) As String
getBidPrice = Application.RTD("rTech.Quotes", , ticker, "bidprice")
End Function
Function getAskSize(ByVal ticker As String) As String
getAskSize = Application.RTD("rTech.Quotes", , ticker, "asksize")
End Function
Function getAskPrice(ByVal ticker As String) As String
getAskPrice = Application.RTD("rTech.Quotes", , ticker, "askprice")
End Function
Function getLast(ByVal ticker As String) As String
getLast = Application.RTD("rTech.Quotes", , ticker, "last")
End Function
基本上就是这样,虽然当我总是打电话给他们时
=getBidSize("XXXX")
它为每次尝试返回#VALUE;我猜它在 Application.RTD 部分崩溃,但我不是 100% 确定,因为当我使用 Debug 时,它只是在我跨过 RTD 调用时“停止”。