title: VB to Delphi translation
body: <p>I'm translating a VB6 code to Delphi 7) </p>
  
  <p>How can I translate the following</p>
  
  <p>Function funcSetupCallBack is defined in an external in DLL</p>
  
  <pre><code>Public Declare Function funcSetUpCallBack&amp; Lib "BUICAP32.DLL" (ByVal nEvent&amp;, ByVal CallBackFunction&amp;)
  </code></pre>
  
  <p>This is how the funcSetupCallBack function is called in the main form</p>
  
  <pre><code>if ( MICRCallBackYN = true ) //If MICR call back is turned on in setup screen and using 4120
      then
        begin
          if ( sScannerType = 'DCC BX7200' )
            then
              begin
                Ret := funcSetUpCallBack( TS200_CB_EVENT_MICR, MICRCallBack ); //Turn on MICR Callback
                Ret := BUICSetParam( CFG_SORT_MODE, 8 );
              end;
          if ( sScannerType = 'Teller Scanner Ts440' )
            then
              begin
                Ret := funcSetUpCallBack( TS200_CB_EVENT_VBMICR, MICRCallBack ); //Turn on MICR Callback VB
              end;
          //ibatchitemsCB = 0  '//Initialize Callback item counter to 0 When using the 'Sort Every Fouth Document Logic'
        end
      else
        begin
          Ret := funcSetUpCallBack( TS200_CB_EVENT_VBMICR, 0 ); //Turn off MICR Callback
          Ret := BUICSetParam( CFG_SORT_MODE, 6 );
        end;
  </code></pre>
  
  <p>And this is the definition of the <strong>MICRCallBack</strong> function</p>
  
  <pre><code>Public Function MICRCallBack(ByVal dwReason&amp;) As Long
      Dim Ret As Long, i As Long, iDocument As Long
      Dim j As Integer
      Dim iScannerType As Long
      Dim strMICR As String * 255, ltr As String, tst As String
  
  iDocument = funcTS200GetMICR(strMICR, 100)
  
      '// Get the MICR
      'iScannerType = BUICGetParam(CFG_MISC_SCANNER_TYPE)
  
          'Every Fourth Document put in option pocket
  '        If ibatchitemsCB &gt; 0 And ibatchitemsCB Mod 4 = 0 Then Ret = funcSetPocket&amp;(1) Else Ret = funcSetPocket&amp;(0)
  '        ibatchitemsCB = ibatchitemsCB + 1
  
          'If Check Upside down put in option Pocket
          If iScannerType = 7200 Then
              Ret = BX7200SetPocket(iDoccument, 0)
              For i = 1 To 10
                  ltr = Mid(strMICR, i, 1)
                  If Asc(ltr) = 0 Then tst = tst &amp; ltr
              Next i
              If Len(tst) &gt; 5 Then Ret = BX7200SetPocket(iDocument, 1) Else Ret = BX7200SetPocket(iDocument, 0)
          Else
               For i = 1 To 10
                  ltr = Mid(strMICR, i, 1)
                  If Asc(ltr) = 0 Then tst = tst &amp; ltr
              Next i
              If Len(tst) &gt; 5 Then Ret = TS400SetPocket(1) Else Ret = TS400SetPocket(0)
          End If
  
      MICRCallBack = 1
  
  End Function        
  </code></pre>
  
  <p>So the question is how can I declare a Delphi function as a parameter for another function declared in an external DLL?</p>
  
  <p>Many thanks for your help and your time.</p>