Problem catching callback from OCX

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • toringe

    #1

    Problem catching callback from OCX

    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_flxPrintSta tus(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(B yVal sender As System.Object, ByVal e
    As System.EventArg s) Handles btnOpen.Click
    Dim i As Integer = ip.flxOpen("192 .168.1.15", "2000")
    If i 1 Then
    Me.currentSocke t = i
    Else
    MsgBox("Connect ion error! Code: " & i)
    End If
    End Sub

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

    'Handle status message callback from terminal
    Private Sub ip_flxPrintStat us(ByVal cStat1 As String, ByVal cStat2
    As String)
    MsgBox("cb_prin tstatus")
    MsgBox(cStat1)
    MsgBox(cStat2)
    Application.DoE vents()
    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(By Val sender As System.Object, ByVal e As
    System.EventArg s) Handles btn100.Click
    Dim i As Integer = ip.flxNorCardTr ansaction(1, 150, 578, 0, 0,
    150, "first", "second")
    MsgBox("Transac tion result: " & i)
    Thread.CurrentT hread.Sleep(300 0)
    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.flxNorCardTr ansaction(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_flxPrintStat us(ByVal cStat1 As String, ByVal cStat2 As
    String)
    MsgBox ("cb_printstatu s")
    MsgBox (cStat1)
    MsgBox (cStat2)
    ok = DoEvents()
    End Sub
    _______________ _______________ _____________


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

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

    __
    Tor Inge
    Norway

  • Lloyd Sheen

    #2
    Re: Problem catching callback from OCX


    "toringe" <tor.inge.schul stad@gmail.comw rote in message
    news:1180004195 .828362.87300@p 47g2000hsd.goog legroups.com...
    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_flxPrintSta tus(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(B yVal sender As System.Object, ByVal e
    As System.EventArg s) Handles btnOpen.Click
    Dim i As Integer = ip.flxOpen("192 .168.1.15", "2000")
    If i 1 Then
    Me.currentSocke t = i
    Else
    MsgBox("Connect ion error! Code: " & i)
    End If
    End Sub
    >
    'Close connection to terminal
    Private Sub btnClose_Click( ByVal sender As System.Object, ByVal e
    As System.EventArg s) Handles btnClose.Click
    Me.ip.flxClose( Me.currentSocke t)
    End Sub
    >
    'Handle status message callback from terminal
    Private Sub ip_flxPrintStat us(ByVal cStat1 As String, ByVal cStat2
    As String)
    MsgBox("cb_prin tstatus")
    MsgBox(cStat1)
    MsgBox(cStat2)
    Application.DoE vents()
    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(By Val sender As System.Object, ByVal e As
    System.EventArg s) Handles btn100.Click
    Dim i As Integer = ip.flxNorCardTr ansaction(1, 150, 578, 0, 0,
    150, "first", "second")
    MsgBox("Transac tion result: " & i)
    Thread.CurrentT hread.Sleep(300 0)
    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.flxNorCardTr ansaction(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_flxPrintStat us(ByVal cStat1 As String, ByVal cStat2 As
    String)
    MsgBox ("cb_printstatu s")
    MsgBox (cStat1)
    MsgBox (cStat2)
    ok = DoEvents()
    End Sub
    _______________ _______________ _____________
    >
    >
    In VB6 i open the connection, push the 100,- button and the
    ip_flxPrintStat us sub immediately pops up a message box with the
    status returned from the terminal.
    >
    In VB.NET the ip_flxPrintStat us 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_flxPrintStat us.
    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

    Comment

    • toringe

      #3
      Re: Problem catching callback from OCX

      On May 24, 7:50 pm, "Lloyd Sheen" <a...@b.cwrot e:
      "toringe" <tor.inge.schul s...@gmail.comw rote in message
      >
      news:1180004195 .828362.87300@p 47g2000hsd.goog legroups.com...
      >
      >
      >
      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_flxPrintSta tus(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(B yVal sender As System.Object, ByVal e
      As System.EventArg s) Handles btnOpen.Click
      Dim i As Integer = ip.flxOpen("192 .168.1.15", "2000")
      If i 1 Then
      Me.currentSocke t = i
      Else
      MsgBox("Connect ion error! Code: " & i)
      End If
      End Sub
      >
      'Close connection to terminal
      Private Sub btnClose_Click( ByVal sender As System.Object, ByVal e
      As System.EventArg s) Handles btnClose.Click
      Me.ip.flxClose( Me.currentSocke t)
      End Sub
      >
      'Handle status message callback from terminal
      Private Sub ip_flxPrintStat us(ByVal cStat1 As String, ByVal cStat2
      As String)
      MsgBox("cb_prin tstatus")
      MsgBox(cStat1)
      MsgBox(cStat2)
      Application.DoE vents()
      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(By Val sender As System.Object, ByVal e As
      System.EventArg s) Handles btn100.Click
      Dim i As Integer = ip.flxNorCardTr ansaction(1, 150, 578, 0, 0,
      150, "first", "second")
      MsgBox("Transac tion result: " & i)
      Thread.CurrentT hread.Sleep(300 0)
      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.flxNorCardTr ansaction(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_flxPrintStat us(ByVal cStat1 As String, ByVal cStat2 As
      String)
      MsgBox ("cb_printstatu s")
      MsgBox (cStat1)
      MsgBox (cStat2)
      ok = DoEvents()
      End Sub
      _______________ _______________ _____________
      >
      In VB6 i open the connection, push the 100,- button and the
      ip_flxPrintStat us sub immediately pops up a message box with the
      status returned from the terminal.
      >
      In VB.NET the ip_flxPrintStat us 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_flxPrintStat us.
      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 :-(

      Comment

      Working...