Problem catching callback from OCX

T

toringe

Hi

I try to connect to a cardreader from a VB.NET 2003 application. The
cardreader manufacturer has provided an OCX to access the reader
trough. The OCX sends status messages back by using callback
functions. It requires me to provide a sub named
'ip_flxPrintStatus(ByVal cStat1 As String, ByVal cStat2 As String)' to
handle status messages returned from the reader.

I have no problem making it work in VB6, but in VB.NET I can not catch
the callback messages.

VB.NET Code:
___________________________________________

Public Class Form1
Inherits System.Windows.Forms.Form

Private currentSocket As Integer

'Open connection to terminal
Private Sub btnOpen_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles btnOpen.Click
Dim i As Integer = ip.flxOpen("192.168.1.15", "2000")
If i > 1 Then
Me.currentSocket = i
Else
MsgBox("Connection error! Code: " & i)
End If
End Sub

'Close connection to terminal
Private Sub btnClose_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles btnClose.Click
Me.ip.flxClose(Me.currentSocket)
End Sub

'Handle status message callback from terminal
Private Sub ip_flxPrintStatus(ByVal cStat1 As String, ByVal cStat2
As String)
MsgBox("cb_printstatus")
MsgBox(cStat1)
MsgBox(cStat2)
Application.DoEvents()
End Sub

'Start purchase of a value of NOK 1.00, this will trigger a status
message to be sent back from terminal...
Private Sub btn100_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btn100.Click
Dim i As Integer = ip.flxNorCardTransaction(1, 150, 578, 0, 0,
150, "first", "second")
MsgBox("Transaction result: " & i)
Thread.CurrentThread.Sleep(3000)
End Sub
End Class

___________________________________________



The following VB6 code works:
___________________________________________

Public socket As Long

'Start purchase of a value of NOK 1.00, this will trigger a status
message to be sent back from terminal...
Private Sub btn100_Click()
i = ip.flxNorCardTransaction(1, 150, 578, 0, 0, 150, "", "")
End Sub

'Close connection to terminal
Private Sub btnClose_Click()
ip.flxClose (socket)
End Sub

'Open connection to terminal
Private Sub btnOpen_Click()
i = ip.flxOpen("192.168.1.15", "2000")
If i > 1 Then
socket = i
Else
MsgBox ("Connection error!. Code: " & i)
End If
ok = DoEvents()
End Sub

'Handle status message callback from terminal
Private Sub ip_flxPrintStatus(ByVal cStat1 As String, ByVal cStat2 As
String)
MsgBox ("cb_printstatus")
MsgBox (cStat1)
MsgBox (cStat2)
ok = DoEvents()
End Sub
___________________________________________


In VB6 i open the connection, push the 100,- button and the
ip_flxPrintStatus sub immediately pops up a message box with the
status returned from the terminal.

In VB.NET the ip_flxPrintStatus never get executed. If anyone has any
suggestions why, I would be a happy man :)

__
Tor Inge
Norway
 
L

Lloyd Sheen

toringe said:
Hi

I try to connect to a cardreader from a VB.NET 2003 application. The
cardreader manufacturer has provided an OCX to access the reader
trough. The OCX sends status messages back by using callback
functions. It requires me to provide a sub named
'ip_flxPrintStatus(ByVal cStat1 As String, ByVal cStat2 As String)' to
handle status messages returned from the reader.

I have no problem making it work in VB6, but in VB.NET I can not catch
the callback messages.

VB.NET Code:
___________________________________________

Public Class Form1
Inherits System.Windows.Forms.Form

Private currentSocket As Integer

'Open connection to terminal
Private Sub btnOpen_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles btnOpen.Click
Dim i As Integer = ip.flxOpen("192.168.1.15", "2000")
If i > 1 Then
Me.currentSocket = i
Else
MsgBox("Connection error! Code: " & i)
End If
End Sub

'Close connection to terminal
Private Sub btnClose_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles btnClose.Click
Me.ip.flxClose(Me.currentSocket)
End Sub

'Handle status message callback from terminal
Private Sub ip_flxPrintStatus(ByVal cStat1 As String, ByVal cStat2
As String)
MsgBox("cb_printstatus")
MsgBox(cStat1)
MsgBox(cStat2)
Application.DoEvents()
End Sub

'Start purchase of a value of NOK 1.00, this will trigger a status
message to be sent back from terminal...
Private Sub btn100_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btn100.Click
Dim i As Integer = ip.flxNorCardTransaction(1, 150, 578, 0, 0,
150, "first", "second")
MsgBox("Transaction result: " & i)
Thread.CurrentThread.Sleep(3000)
End Sub
End Class

___________________________________________



The following VB6 code works:
___________________________________________

Public socket As Long

'Start purchase of a value of NOK 1.00, this will trigger a status
message to be sent back from terminal...
Private Sub btn100_Click()
i = ip.flxNorCardTransaction(1, 150, 578, 0, 0, 150, "", "")
End Sub

'Close connection to terminal
Private Sub btnClose_Click()
ip.flxClose (socket)
End Sub

'Open connection to terminal
Private Sub btnOpen_Click()
i = ip.flxOpen("192.168.1.15", "2000")
If i > 1 Then
socket = i
Else
MsgBox ("Connection error!. Code: " & i)
End If
ok = DoEvents()
End Sub

'Handle status message callback from terminal
Private Sub ip_flxPrintStatus(ByVal cStat1 As String, ByVal cStat2 As
String)
MsgBox ("cb_printstatus")
MsgBox (cStat1)
MsgBox (cStat2)
ok = DoEvents()
End Sub
___________________________________________


In VB6 i open the connection, push the 100,- button and the
ip_flxPrintStatus sub immediately pops up a message box with the
status returned from the terminal.

In VB.NET the ip_flxPrintStatus never get executed. If anyone has any
suggestions why, I would be a happy man :)

__
Tor Inge
Norway

What I do not see is how you tell the OCX to use the sub ip_flxPrintStatus.
I would doubt that it needs that name but needs the correct signature.
Somewhere in the VB6 program there most be something to tell the "ip" object
(which is not shown in your code provided) to use the correct statement.

Lloyd Sheen
 
T

toringe

What I do not see is how you tell the OCX to use the sub ip_flxPrintStatus.
I would doubt that it needs that name but needs the correct signature.
Somewhere in the VB6 program there most be something to tell the "ip" object
(which is not shown in your code provided) to use the correct statement.

Lloyd Sheen

Thanks for your reply! I have now tried to code the VB6 sample from
scratch to be sure i didn't miss anything in the sample code, and I'm
not telling the ip-object the name of the callback function anywhere.
The documentation specifies that both the name and the signature of
the callback function must be kept like this. Still stuck :-(
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top