I am trying to work through the examples I have seen, but I can not seem to get past some errors. Does anyone have a simple COM example that can be used to build upon?
Creating COM Component Add-in with Visual Studio 2005
Jul 20, 2007
3 Replies
Here is one I built to show the credit card name on the receipt. My VB is rusty but it works.
Option Explicit
Public Function Process(Session As Object) As Boolean On Error GoTo ErrorHandler ''''''''''''''''''''''''''''''''''''''''''''''''''''''' 'For Setup and testing only: Public Function Process(Session As QSRules.SessionClass) As Boolean 'Installation 'Increment HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Retail Management System\Store Operations\Hooks\count By 1 'Set Next Empty HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Retail Management System\Store Operations\Hooks\XXX 'To HookType = 0, Parameter = 1, ObjectName=DLLFileName.ClassName 'Uses Session.Variable1 on Receipt(This can be changed below if it conflicts with another addin) 'Register DLL With regsvr32 "C:\Path\DLLName.dll" - Must be done each time DLL is Modified 'The Function can only capture the name from the first Credit Card Ran ''''''''''''''''''''''''''''''''''''''''''''''''''''
Dim x As Variant Dim arrCCInfo() As String
'Cycle through tenders For Each x In Session.Transaction.Tenders 'Find tender with the swiped card If x.Swiped = True Then arrCCInfo = Split(x.Track1, "^") arrCCInfo = Split(arrCCInfo(1), "/") Session.Variable(1) = arrCCInfo(1) & " " & arrCCInfo(0) 'Uncomment MsgBox to see Account Holders Name 'MsgBox (Session.Variable(1)) Exit For End If Next Process = True 'Continue Exit Function
ErrorHandler: MsgBox ("An Error has occurred, please contact IT Admin" & vbCrLf & "Please Continue") Resume Next
End Function
Use RegAsm to register the dotNET library how COM component (select in project settings the field "Register for COM Component").
cod
Join the Discussion
Have something to add? Share your thoughts — no account required.
Didn't find your answer?
Ask the community — no account required