Trying Out TsSample(VB) - minor problem
we are trying to collect Current T&Sales data...
We are using VB6 only - we do not use VB.net
Refs Include:......
Visual Basic for Applicaitons
Visual Basic Runtime Objects and Procedures
Visual Basic Objects and Procedures
OLE Automation
IESignal
We have put in the correct username
we put in the IEsignal ref and code compiles and form shows just fine.
We put in MSFT in symbol area and click start and code starts to run and then we get a runtime break in Sub FillTS line 11 of that Sub ...
item = esignal.GetTimeSalesBar(lTsHandle, lBar)
******************************************
Dim WithEvents esignal As IESignal.Hooks
Dim sLastSymbol As String
Dim lTsHandle As Long
Dim lLastTsCount As Long
Dim lLastTsRtCount As Long
Private Sub ReleaseTS()
If lTsHandle <> 0 Then
esignal.ReleaseTimeSales lTsHandle
lTsHandle = 0
lLastTsCount = 0
End If
End Sub
Private Sub cmdRelease_Click()
ReleaseTS
End Sub
Private Sub cmdRequest_Click()
Dim sSymbol As String
sSymbol = edtSymbol.Text
Trim (sSymbol)
If sSymbol = "" Then
Exit Sub
End If
ReleaseTS
Dim tsFilter As IESignal.TimeSalesFilter
tsFilter.sSymbol = sSymbol
tsFilter.bQuotes = True
tsFilter.bTrades = True
tsFilter.lNumDays = 1
tsFilter.bFilterPrice = False
tsFilter.bFilterVolume = False
tsFilter.bFilterQuoteExchanges = False
tsFilter.bFilterTradeExchanges = False
list.Clear
lTsHandle = esignal.RequestTimeSales(tsFilter)
End Sub
Private Sub Form_Load()
Set esignal = New IESignal.Hooks
lTsHandle = 0
lLastTsCount = 0
esignal.SetApplication ("username")
End Sub
Private Sub Form_Unload(Cancel As Integer)
ReleaseTS
Set esignal = Nothing
End Sub
Private Sub esignal_OnTimeSalesChanged(ByVal lHandle As Long)
FillTS
End Sub
Private Function FormatTS(item As TimeSalesData)
Dim sRet As String
If item.DataType = tsdNA Then
sRet = "NA"
Else
sRet = Str$(item.dtTime)
If item.DataType = tsdTRADE Then
sRet = sRet + ", Trade"
ElseIf item.DataType = tsdBID Then
sRet = sRet + ", Bid"
ElseIf item.DataType = tsdASK Then
sRet = sRet + ", Ask"
End If
sRet = sRet + ", " + Str$(item.dPrice)
sRet = sRet + ", " + Str$(item.lSize)
sRet = sRet + ", " + item.sExchange
End If
FormatTS = sRet
End Function
Private Sub FillTS()
Dim lNumBars, lNumRtBars, lBar, lDiff As Long
Dim item As IESignal.TimeSalesData
' only showing realtime bars.
lNumRtBars = esignal.GetNumTimeSalesRtBars(lTsHandle)
lNumBars = esignal.GetNumTimeSalesBars(lTsHandle)
' how many new bars since last time?
lDiff = (lNumRtBars - lLastTsRtCount) * -1
For lBar = lDiff + 1 To 0
item = esignal.GetTimeSalesBar(lTsHandle, lBar) **BREAKS
sBar = FormatTS(item)
list.AddItem sBar, 0
Next lBar
lLastTsRtCount = lNumRtBars
End Sub
we are trying to collect Current T&Sales data...
We are using VB6 only - we do not use VB.net
Refs Include:......
Visual Basic for Applicaitons
Visual Basic Runtime Objects and Procedures
Visual Basic Objects and Procedures
OLE Automation
IESignal
We have put in the correct username
we put in the IEsignal ref and code compiles and form shows just fine.
We put in MSFT in symbol area and click start and code starts to run and then we get a runtime break in Sub FillTS line 11 of that Sub ...
item = esignal.GetTimeSalesBar(lTsHandle, lBar)
******************************************
Dim WithEvents esignal As IESignal.Hooks
Dim sLastSymbol As String
Dim lTsHandle As Long
Dim lLastTsCount As Long
Dim lLastTsRtCount As Long
Private Sub ReleaseTS()
If lTsHandle <> 0 Then
esignal.ReleaseTimeSales lTsHandle
lTsHandle = 0
lLastTsCount = 0
End If
End Sub
Private Sub cmdRelease_Click()
ReleaseTS
End Sub
Private Sub cmdRequest_Click()
Dim sSymbol As String
sSymbol = edtSymbol.Text
Trim (sSymbol)
If sSymbol = "" Then
Exit Sub
End If
ReleaseTS
Dim tsFilter As IESignal.TimeSalesFilter
tsFilter.sSymbol = sSymbol
tsFilter.bQuotes = True
tsFilter.bTrades = True
tsFilter.lNumDays = 1
tsFilter.bFilterPrice = False
tsFilter.bFilterVolume = False
tsFilter.bFilterQuoteExchanges = False
tsFilter.bFilterTradeExchanges = False
list.Clear
lTsHandle = esignal.RequestTimeSales(tsFilter)
End Sub
Private Sub Form_Load()
Set esignal = New IESignal.Hooks
lTsHandle = 0
lLastTsCount = 0
esignal.SetApplication ("username")
End Sub
Private Sub Form_Unload(Cancel As Integer)
ReleaseTS
Set esignal = Nothing
End Sub
Private Sub esignal_OnTimeSalesChanged(ByVal lHandle As Long)
FillTS
End Sub
Private Function FormatTS(item As TimeSalesData)
Dim sRet As String
If item.DataType = tsdNA Then
sRet = "NA"
Else
sRet = Str$(item.dtTime)
If item.DataType = tsdTRADE Then
sRet = sRet + ", Trade"
ElseIf item.DataType = tsdBID Then
sRet = sRet + ", Bid"
ElseIf item.DataType = tsdASK Then
sRet = sRet + ", Ask"
End If
sRet = sRet + ", " + Str$(item.dPrice)
sRet = sRet + ", " + Str$(item.lSize)
sRet = sRet + ", " + item.sExchange
End If
FormatTS = sRet
End Function
Private Sub FillTS()
Dim lNumBars, lNumRtBars, lBar, lDiff As Long
Dim item As IESignal.TimeSalesData
' only showing realtime bars.
lNumRtBars = esignal.GetNumTimeSalesRtBars(lTsHandle)
lNumBars = esignal.GetNumTimeSalesBars(lTsHandle)
' how many new bars since last time?
lDiff = (lNumRtBars - lLastTsRtCount) * -1
For lBar = lDiff + 1 To 0
item = esignal.GetTimeSalesBar(lTsHandle, lBar) **BREAKS
sBar = FormatTS(item)
list.AddItem sBar, 0
Next lBar
lLastTsRtCount = lNumRtBars
End Sub
Comment