Welcome Guest,Register Now
Log In

ANT Forum

Welcome guest, please Login or Register

   

VB.NET Application for the ANTstick event handler problem

Rank

Total Posts: 22

Joined 0

PM

I have been writing a VB.NET application for the ANTstick and have been having some success. I have been able to open the device and transmit data. However, I am having some difficulty with the eventhandler for receiving data from the stick. The example in DEMO_NET shows what needs to be done, but obviously, this is C++.

The following code shows what I have done so far.

//This creates an instance of the ANT device.
Public antstick As ANT_Managed_Library.ANT_Device = New ANT_Managed_Library.ANT_Device()

//This creates a channel object of the ANT_Channel type.
Dim Channel As ANT_Managed_Library.ANT_Channel

//This populates the channel object with data from the stick.
Channel = antstick.getChannel(5)

The next line attempts to direct the channelResponse event to use the function ChResponse when data is received by the stick.

RaiseEvent Channel.channelResponse(AddressOf ChResponse)

The above line fails because the RaiseEvent command doesn't recognise the Channel as an event. Without the RaiseEvent command, it says that the channelResponse is an event and cannot be called directly and it says to use the RaiseEvent command.

I am going round in circles, there does not seem to be an obvious way to ensure that the event triggers the correct function. Unless I have missed something obvious. Has anyone else used VB.NET to write an application for the ANTstick?      
RankRankRankRank

Total Posts: 523

Joined 2012-11-15

PM

Hello Again,

I have found the solution to my problem. The correct line is as follows.

AddHandler Channel.channelResponse, AddressOf ChResponse

My lack of knowlege of .NET I'm afraid.