sunny 發表於 13-3-13 01:46
... Function SKQuoteLib .... 要有空格喔,
其他的有照貼嗎?
sunny兄,您好: VB6 程式碼如下, 執行時會發生 AddressOf 運算子的用法不正確(如紅色字) 請幫我看看,謝謝。 Option Explicit '*** 宣告DLL Private Declare Function SKQuoteLib_Initialize Lib"SKQuoteLib.dll" (ByVal strID As String, ByVal strPass As String) AsLong Private Declare Function SKQuoteLib_EnterMonitor Lib"SKQuoteLib.dll" () As Long Private Declare Function SKQuoteLib_AttachConnectionCallBack Lib"SKQuoteLib.dll" (ByVal Func As Long) As Long Private Declare Function SKQuoteLib_AttachTicksCallBack Lib"SKQuoteLib.dll" (ByVal Func As Long) As Long Private Declare Function SKQuoteLib_RequestTicks Lib"SKQuoteLib.dll" (ByRef Page As Integer, ByVal Stock As String) AsLong Private Declare Function SKQuoteLib_GetTick Lib"SKQuoteLib.dll" (ByVal Market As Integer, ByVal Index As Integer,ByVal Ptr As Long, ByRef Tick As TTick) As Long '*** 定義TTick結構 Private Type TTick Ptr AsLong Time As Long Bid As Long Ask As Long Close As Long Qty As Long End Type '*** 呼叫DLL Public Function Login(ByVal AcNo As String,ByVal Pwd As String) As Integer Dim status As Long status = status + SKQuoteLib_Initialize(AcNo,Pwd) status = status +SKQuoteLib_AttachConnectionCallBack(AddressOfOnConnectionBack) status = status +SKQuoteLib_AttachTicksCallBack(AddressOf OnTicks) If status = 0 Then status = SKQuoteLib_EnterMonitor() Login = 0 Else: Login = -1 End If End Function '*** 接收ConnectionCallBack Sub OnConnectionBack(ByValkind As Long, ByVal code As Long) If code = 0 Then MsgBox "報價伺服器登入成功!!" Else MsgBox "報價中斷!!" EndIf End Sub '** 接收Tick報價 Sub OnTicks(ByVal MarketNo As Integer, ByValIndex As Integer, ByVal Ptr As Long) Dim status As Long Dim Tick As TTick status = SKQuoteLib_GetTick(MarketNo, Index,Ptr, Tick) txtPtr.Text = Tick.Ptr txtTime.Text = Tick.Time txtBid.Text = Tick.Bid txtAsk.Text = Tick.Ask txtClose.Text = Tick.Close txtQty.Text = Tick.Qty End Sub '** 登入帳號密碼按鈕 Private SubbtnCheckin_Click() Dim Rn As Integer Rn = Login("身分證字號", "密碼") If Rn = 0 Then MsgBox "登入成功" Else MsgBox "登入失敗!!" End If End Sub '** 開始接收報價按鈕 Private Sub btnQuote_Click() Dim ComIds As String Dimstatus As Long ComIds= "TX00" status= SKQuoteLib_RequestTicks(-1, ComIds) End Sub |