2012-08-03 79 views
0

我有一個RTD服務器,用於向Excel發送數據和從Excel發送數據。我試圖通過在Excel的VBA模塊中構建一些簡單的函數來讓用戶更容易地獲取數據,以便在不知道整個後端的情況下獲取數據。Excel中的模塊函數返回#VALUE

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%肯定的,因爲使用調試時,它只是「停止」,當我跨過RTD調用。

回答

0

這是造成問題的主要原因不是由於任何事情,而是因爲RTD函數想要一個空白的第二個參數而不僅僅是忽略它,不像你會這樣做,如果你在功能欄Excel中。

因此,職能應該是這樣的:

getLast = Application.RTD("rTech.Quotes", "", ticker, "last")