Question Point Of Service

bdinnocenzo

Active member
Joined
Oct 22, 2009
Messages
38
Location
Massachusetts
Programming Experience
5-10
Hi all,

This is my first post so if I've posted to the wrong area I apologize. I've searched this site and the web for help in this area and so far have come up empty. I'm new to VB.NET, been programming (as a hobby most recently) for about 10 years. Most of my recent work has been in VB6. I am in the process of re-writing an application I did in VB6 that, among other stuff, accepts credit cards using a card reader plugged into a USB port. In VB6 this was handled through an ActiveX control, but in VB.NET I was was lead to using Microsoft's POS for .NET V1.12 by the card reader manufacturer.

I've installed all of the POS for .NET software and ran a test application from the vendor (MagTek) and all seems to work fine with one of their readers. The test app is written in C#.

I'm trying to incorporate the mag card reader into the VB.NET application and do not know C# enough to understand the code.

When I try to open and access the reader I get an error stating "The value of the 'DevicePath' property must be defined by the service object before Open() can be called."

Here is the quick snipet of what I'm doing. It's just a few lines in a form's load routine...

VB.NET:
Imports Microsoft.PointOfService
Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim mtcr As New MagTekServiceObject.MagTekMsr

        mtcr.Open() ' This is where I get the error...

    End Sub

End Class

I can't seem to find the point at which I would define the 'Device Path'.

Thanks in advance for any help.

-Bill
 
So I assume nobody has worked with POS on VB.Net before... Oh well.
 
Here is a C# to VB.Net converter. I recommend using small amounts of code to convert at a time - each method/Sub/Event separate. :cool:

Also when posting a problem if there is an error copy the error message so we can see it - I don't know if any of us are clairvoyant. Happy coding...
 
I will try the C# to VB Code Converter...assuming I can find the key elements. The failure that I get, as I indicated in my original post is ""The value of the 'DevicePath' property must be defined by the service object before Open() can be called." I get this when I try to invoke the open method.

I've combed through the C# code and I think this might be the important stuff relative to what I need to do -- e.g. Open and access the device. If this gives anyone a hint please let me know. Thanks!

VB.NET:
        private void OpenDevice(TreeNode node)
        {
            if (node == null || node.Tag == null)
                return;

            PosDeviceTag tag = (PosDeviceTag) node.Tag;

            if (tag == null)
                return;

            try
            {
                DeviceInfo device = tag.DeviceInfo;

                if (tag.posCommon == null)
                {
                    tag.posCommon = (PosCommon)posExplorer.CreateInstance(device);
                    Output.Text = "Created instance of device: " + device.ServiceObjectName + "\r\n" + Output.Text;
                }
                else
                {
                    Output.Text = "Using existing instance of device: " + device.ServiceObjectName + "\r\n" + Output.Text;
                }

                tag.posCommon.Open();
                Output.Text = "Opened device: " + device.ServiceObjectName + "\r\n" + Output.Text;

                // Display the screen for this device
                ShowDeviceScreen(tag);

                // Tell the device screen that it is now opened
                if (tag.screen != null)
                    tag.screen.SetOpened(true);

                // Update the common UI properties
                //SetDeviceProperties(node);

                // Bold the font for this device in the DeviceTree to indicate it's created
                node.NodeFont = new Font(DeviceTree.Font, FontStyle.Bold);
                node.Text = node.Text;

                // Hook up event handlers for device (only error event for now)
                HookUpEvents(tag.posCommon, true);
            }
            catch( Exception ae )
            {
                tag.posCommon = null;
                ShowException(ae);
            }
            finally
            {
                SetButtonState();
            }
        }

        private void CloseDevice(TreeNode node)
        {
            if (node == null)
                return;

            // Unbold the treenode
            node.NodeFont = new Font(DeviceTree.Font, FontStyle.Regular);

            PosDeviceTag tag = node.Tag as PosDeviceTag;
            try
            {
                if (tag == null || tag.posCommon == null || tag.posCommon.State == ControlState.Closed)
                    return;

                tag.posCommon.Close();

                // Tell the device screen that it is now Closed
                if (tag.screen != null)
                {
                    tag.screen.SetOpened(false);
                    if (DevicePanel.Controls.Contains(tag.screen))
                        DevicePanel.Controls.Remove(tag.screen);
                    tag.screen = null;
                }

                HookUpEvents(tag.posCommon, false);
                tag.posCommon = null;
                
            }
            catch(Exception ae)
            {
                tag.posCommon = null;
                ShowException(ae);
            }
            finally
            {
                SetButtonState();
            }

        }
 
Back
Top