usb cash drawer vb codes...help me pls

b_c

Registered User.
Local time
Today, 00:16
Joined
Aug 5, 2008
Messages
87
hello...

i bought a usb cash drawer for a POS application i'm building in Access...

...can anyone kindly tell me how i utilize the following codes that i captured from screen shots of their "demo" program that was included in the software package. i'm a dummy when it comes to this vb coding...i've got a book and another on the way, but was hoping someone could help me. here's the screenshots of their demo:

there's a button in the demo that's called "check health"...when depressed the following code pops up in the provided window:
attachment.php




then, if you press the "open" button in the demo, the following codes shows (but drawer doesn't open):
attachment.php



it's not until you press the "check health" button again, does the drawer open:
attachment.php



then when you press the "close" button in the demo program:
attachment.php





pretty simple...one thing to note, though...if you don't press the "close" button and then try to "open", it won't work.



SO......


...can anyone help this clueless guy?



cheers,

b_c
 

Attachments

  • cd-checkhealth.JPG
    cd-checkhealth.JPG
    46 KB · Views: 5,441
  • cd-open.JPG
    cd-open.JPG
    47.1 KB · Views: 4,982
  • cd-openthencheckhealth.JPG
    cd-openthencheckhealth.JPG
    50.1 KB · Views: 5,060
  • cd-closed.JPG
    cd-closed.JPG
    52.3 KB · Views: 5,038
hello...

i bought a usb cash drawer for a POS application i'm building in Access...

...can anyone kindly tell me how i utilize the following codes that i captured from screen shots of their "demo" program that was included in the software package. i'm a dummy when it comes to this vb coding...i've got a book and another on the way, but was hoping someone could help me. here's the screenshots of their demo:

there's a button in the demo that's called "check health"...when depressed the following code pops up in the provided window:
attachment.php




then, if you press the "open" button in the demo, the following codes shows (but drawer doesn't open):
attachment.php



it's not until you press the "check health" button again, does the drawer open:
attachment.php



then when you press the "close" button in the demo program:
attachment.php





pretty simple...one thing to note, though...if you don't press the "close" button and then try to "open", it won't work.



SO......


...can anyone help this clueless guy?



cheers,

b_c


should i be looking at ado functionality w/in access? ...this seems like the right place (at least the book examples look fairly similar to the code above).


b_c
 
should i be looking at ado functionality w/in access? ...this seems like the right place (at least the book examples look fairly similar to the code above).


b_c


okay...i was missing a .txt file with this info in it...does this help me? :(

*****************************************************************
* *
* Posiflex CR-4xx5-II Series USB CR DLL v1.03 Programming Guide *
* *
*****************************************************************

The driver required to control the Posiflex USB Cash Drawer
is called "USBCR.DLL". When the Posiflex USB Cash Drawer Test
Program is installed, this driver is stored in folder
"C:\Windows\System" if the default Windows folder is
"C:\Windows". Please preserve this file "USBCR.DLL" in the
system folder for your software to control the Posiflex USB
Cash Drawer even if you want to uninstall the Posiflex test
program.

The driver "USBCR.DLL" provides 7 function calls:
The 1--5 functions are for CR-4XX5-II series to use.
The 6--7 functions are for CR-4XX5 series to use.
The examples of Visual Basic are list below.


1. Public Declare Function OpenUSBcr LIB "usbcr.dll" () As Long
=========
' must be called before calling other functions
' return 0 on success


2. Public Declare Function CloseUSBcr Lib "usbcr.dll" () As Long
==========
' call this function before exiting your program
' return 0 on success


3. Public Declare Function DrawerOpen Lib "usbcr.dll" (ByVal ID As Long) As Long
==========
' return 0 on sending commands successfully, -1 on error
' 'ID' is the drawer number from 0 to 7


4. Public Declare Function DrawerState Lib "usbcr.dll" (ByVal ID As Long) As Long
===========
' return the drawer status
' high nibble is the drawer ID, and
' low nibble is 0 if drawer is open, 1 if drawer is closed
' return -1 on error


5. Public Declare Function RetrieveStatistics Lib "usbcr.dll" (ByVal ID As Long, ByVal idx As Long, ByRef buf As Any, ByVal size As Long) As Long
==================
' return 0 on sending commands successfully, -1 on error
' 'size' is the number of bytes which can be held by 'buf'
' 'buf' will hold the value read from memory in cash drawer
' This function used to Retrieve the device statistics of Unified POS1.8.

6. Public Declare Function OpenUSB Lib "usbcr.dll" () As Long
=======
' must be called before calling other functions
' return 0 on success
' This function is for CR-4xx5 Series to use,
' and it can drive CR-4xx5-II too.


7. Public Declare Function CloseUSB Lib "usbcr.dll" () As Long
========
' call this function before exiting your program
' return 0 on success
' This function is for CR-4xx5 Series to use.
' and it can drive CR-4xx5-II too.


Note : For C++ programs: use __stdcall compiler option
 
You're going to need to look at the code of your demo program. Just open the VB editor for the project and look through the code. That should give you a little bit of an idea how they got it to work. You'll be able to ask a much better question then.
 
You're going to need to look at the code of your demo program. Just open the VB editor for the project and look through the code. That should give you a little bit of an idea how they got it to work. You'll be able to ask a much better question then.


Hey george...thanks for the reply! Houston? ...bet u r freezin ur b's off today!

As for the code...can u take a look at my post #3 in this thread and tell me if that will help my cause? It seems from what I've read so far that I will have to call on some of the functionality that's there.

b_c
 
Yes, it is very cold here today, colder tomorrow I believe. I'm lead to believe that it is caused by global warming.

I'm very interested in this problem because I've never interfaced with a USB device before and you just never know when you'll need something like that. The code in post 3 is not really very helpful for answering your question.

If you'd like to post the sample database, maybe somebody could find the code and show you where it is and suggest what you might want to do with it. That somebody might even be me. Or (if you're lucky), it could be somebody better.

How To Upload A Database To The Forum
 
Hey george...thanks for the reply! Houston? ...bet u r freezin ur b's off today!

As for the code...can u take a look at my post #3 in this thread and tell me if that will help my cause? It seems from what I've read so far that I will have to call on some of the functionality that's there.

b_c


Code:
Option Compare Database

Public Declare Function OpenUSBcr Lib "usbcr.dll" () As Long
Public Declare Function DrawerOpen Lib "usbcr.dll" (ByVal ID As Long) As Long
Public Declare Function CloseUSBcr Lib "usbcr.dll" () As Long
Public Declare Function DrawerState Lib "usbcr.dll" (ByVal ID As Long) As Long
Public Declare Function RetrieveStatistics Lib "usbcr.dll" (ByVal ID As Long, ByVal idx As Long, ByRef buf As Any, ByVal size As Long) As Long
Public Declare Function OpenUSB Lib "usbcr.dll" () As Long
Public Declare Function CloseUSB Lib "usbcr.dll" () As Long


Private Sub Image20_Click()
OpenUSBcr
DrawerOpen 7
CloseUSBcr
End Sub

no worky?? am i doing something wrong? i declared the functions globally, then i'm trying to test to see if i click an image if the drawer will pop...

keep getting error...somethings missing, i know...but ???


b_c
 
Code:
Option Compare Database

Public Declare Function OpenUSBcr Lib "usbcr.dll" () As Long
Public Declare Function DrawerOpen Lib "usbcr.dll" (ByVal ID As Long) As Long
Public Declare Function CloseUSBcr Lib "usbcr.dll" () As Long
Public Declare Function DrawerState Lib "usbcr.dll" (ByVal ID As Long) As Long
Public Declare Function RetrieveStatistics Lib "usbcr.dll" (ByVal ID As Long, ByVal idx As Long, ByRef buf As Any, ByVal size As Long) As Long
Public Declare Function OpenUSB Lib "usbcr.dll" () As Long
Public Declare Function CloseUSB Lib "usbcr.dll" () As Long


Private Sub Image20_Click()
OpenUSBcr
DrawerOpen 7
CloseUSBcr
End Sub
no worky?? am i doing something wrong? i declared the functions globally, then i'm trying to test to see if i click an image if the drawer will pop...

keep getting error...somethings missing, i know...but ???


b_c


should i get rid of the text "Public Declare " in the global declarations??



b_c
 
Not much to go on. What is the error?

Do you know you're not collecting the return value from the functions?

Why aren't you working with the demo program? Start from something that works and then modify it to suit your needs?
 
Not much to go on. What is the error?

Do you know you're not collecting the return value from the functions?

Why aren't you working with the demo program? Start from something that works and then modify it to suit your needs?


found the vb code for the demo program...

Code:
VERSION 5.00
Object = "{CCB90040-B81E-11D2-AB74-0040054C3719}#1.0#0"; "OposCashDrawer.ocx"
Begin VB.Form Form1 
   AutoRedraw      =   -1  'True
   Caption         =   "Posiflex Cash Drawer OPOS Control Demo"
   ClientHeight    =   6660
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   6795
   BeginProperty Font 
      Name            =   "Arial"
      Size            =   9
      Charset         =   0
      Weight          =   400
      Underline       =   0   'False
      Italic          =   0   'False
      Strikethrough   =   0   'False
   EndProperty
   KeyPreview      =   -1  'True
   LinkTopic       =   "Form1"
   ScaleHeight     =   6660
   ScaleWidth      =   6795
   StartUpPosition =   2  'CenterScreen
   Begin VB.TextBox Text1 
      Height          =   330
      Left            =   2760
      TabIndex        =   13
      Text            =   "CR Demo"
      Top             =   120
      Width           =   1575
   End
   Begin VB.CommandButton Command7 
      Caption         =   "release"
      Height          =   495
      Left            =   5520
      TabIndex        =   10
      Top             =   3240
      Width           =   1215
   End
   Begin VB.CommandButton Command6 
      Caption         =   "claim"
      Height          =   495
      Left            =   5520
      TabIndex        =   9
      Top             =   2640
      Width           =   1215
   End
   Begin VB.Frame Frame5 
      Caption         =   "Device Statistics"
      Height          =   2040
      Left            =   120
      TabIndex        =   5
      Top             =   4560
      Width           =   6600
      Begin VB.TextBox txtRetrieveSt 
         Height          =   765
         Left            =   100
         MultiLine       =   -1  'True
         ScrollBars      =   2  'Vertical
         TabIndex        =   7
         Top             =   600
         Width           =   6375
      End
      Begin VB.CommandButton cmdRetrieveSt 
         Caption         =   "Retrieve Statistics"
         Height          =   435
         Left            =   120
         TabIndex        =   6
         Top             =   1440
         Width           =   1695
      End
      Begin VB.Label Label6 
         Caption         =   "RetrieveStatistics parameter"
         Height          =   255
         Left            =   100
         TabIndex        =   8
         Top             =   300
         Width           =   2775
      End
   End
   Begin VB.ListBox List1 
      Height          =   3435
      Left            =   240
      TabIndex        =   4
      Top             =   480
      Width           =   4695
   End
   Begin VB.CommandButton Command4 
      Caption         =   "Exit"
      Height          =   495
      Left            =   5520
      TabIndex        =   3
      Top             =   1920
      Width           =   1215
   End
   Begin VB.CommandButton Command3 
      Caption         =   "Close"
      Height          =   495
      Left            =   5520
      TabIndex        =   2
      Top             =   1320
      Width           =   1215
   End
   Begin VB.CommandButton Command2 
      Caption         =   "Check Health"
      Height          =   495
      Left            =   5520
      TabIndex        =   1
      Top             =   720
      Width           =   1215
   End
   Begin VB.CommandButton Command1 
      Caption         =   "Open"
      Height          =   495
      Left            =   5520
      TabIndex        =   0
      Top             =   120
      Width           =   1215
   End
   Begin VB.Label Label2 
      Caption         =   "Cash Drawer Device Name:"
      Height          =   255
      Left            =   240
      TabIndex        =   14
      Top             =   120
      Width           =   2415
   End
   Begin VB.Label lblSTATUS 
      Alignment       =   2  'Center
      BorderStyle     =   1  'Fixed Single
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   12
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H000000FF&
      Height          =   345
      Left            =   3360
      TabIndex        =   12
      Top             =   4080
      Width           =   1620
   End
   Begin VB.Label Label1 
      Alignment       =   1  'Right Justify
      Caption         =   "Cash Drawer status:"
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   9
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   1080
      TabIndex        =   11
      Top             =   4080
      Width           =   1935
   End
   Begin OposCashDrawer_1_8_LibCtl.OPOSCashDrawer Posiflex_CR1 
      Left            =   5040
      OleObjectBlob   =   "Form1.frx":0000
      Top             =   720
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim ob As Object
Dim OposSuccess
Dim OposChExternal

Private Sub Command1_Click()
Set ob = Posiflex_CR1
 
    Cls
    List1.Clear
    List1.AddItem "ob.Open()= " + Str(ob.Open(Text1.Text))
    'List1.AddItem "ob.Claim()= " + Str(ob.Claim(1000))
    ob.DeviceEnabled = True
    List1.AddItem "ob.DeviceEnabled= " + Str(ob.DeviceEnabled)
    DoEvents
    List1.AddItem "ob.DeviceName= " + ob.DeviceName
    List1.AddItem "CapMultiDrawer: " + Str(ob.CapStatusMultiDrawerDetect)
    List1.AddItem ""
    List1.ListIndex = List1.ListCount - 1
    If Posiflex_CR1.DrawerOpened = True Then
        lblSTATUS.ForeColor = &HFF&
        lblSTATUS.Caption = "OPENED"
    Else
        lblSTATUS.ForeColor = &H80000012
        lblSTATUS.Caption = "CLOSED"
    End If
    DoEvents
 
    ' --------------------------------------------------
    ' the demonstration device name "CR Demo"
    ' can be changed from the registery by using
    ' Posiflex OPOS Manager
End Sub

Private Sub Command2_Click()
Set ob = Posiflex_CR1
Dim buf As String

    List1.AddItem "CapStatus= " + Str(ob.CapStatus)
    DoEvents
    List1.AddItem "DrawerOpened= " + Str(ob.DrawerOpened)
    DoEvents
    List1.AddItem "OpenDrawer= " + Str(ob.OpenDrawer())
    DoEvents
    List1.AddItem "DrawerOpened= " + Str(ob.DrawerOpened)
    DoEvents
    List1.AddItem "CheckHealth= " + Str(ob.CheckHealth(OposChExternal))
    DoEvents
    List1.AddItem "DrawerOpened= " + Str(ob.DrawerOpened)
    DoEvents
    'List1.AddItem "WaitForClosed= " + Str(ob.WaitForDrawerClose(1000, 1000, 1000, 1000))

' ---------------------------------------------
'    List1.AddItem "Release: " + Str(ob.Release)
'
'    List1.AddItem "ob.DeviceEnabled= " + Str(ob.DeviceEnabled)
'    List1.AddItem "ob.Claimed= " + Str(ob.Claimed)
'    List1.AddItem "ob.DeviceName= " + ob.DeviceName
'    List1.AddItem "OpenDrawer: " + Str(ob.OpenDrawer)
'    List1.AddItem ""
'    List1.ListIndex = List1.ListCount - 1
'    DoEvents
'
'    ob.DeviceEnabled = False
'    List1.AddItem "ob.DeviceEnabled= " + Str(ob.DeviceEnabled)
'    List1.AddItem "ob.Claimed= " + Str(ob.Claimed)
'    List1.AddItem "ob.DeviceName= " + ob.DeviceName
'    List1.AddItem "OpenDrawer: " + Str(ob.OpenDrawer)
'    List1.AddItem ""
'    List1.ListIndex = List1.ListCount - 1
'    DoEvents
'
'    ob.DeviceEnabled = True
'    DoEvents
'    List1.AddItem "ob.DeviceEnabled= " + Str(ob.DeviceEnabled)
'    List1.AddItem "ob.Claimed= " + Str(ob.Claimed)
'    List1.AddItem "ob.DeviceName= " + ob.DeviceName
'    List1.AddItem "OpenDrawer: " + Str(ob.OpenDrawer)
'    List1.AddItem ""
'    List1.ListIndex = List1.ListCount - 1
'    DoEvents
'
'    List1.AddItem "Claim: " + Str(ob.Claim(1000))
'
'    List1.AddItem "ob.DeviceEnabled= " + Str(ob.DeviceEnabled)
'    List1.AddItem "ob.Claimed= " + Str(ob.Claimed)
'    List1.AddItem "ob.DeviceName= " + ob.DeviceName
'    List1.AddItem "OpenDrawer: " + Str(ob.OpenDrawer)
'    List1.AddItem ""
'    List1.ListIndex = List1.ListCount - 1
'    DoEvents
'
'    ob.DeviceEnabled = False
'    List1.AddItem "ob.DeviceEnabled= " + Str(ob.DeviceEnabled)
'    List1.AddItem "ob.Claimed= " + Str(ob.Claimed)
'    List1.AddItem "ob.DeviceName= " + ob.DeviceName
'    List1.AddItem "OpenDrawer: " + Str(ob.OpenDrawer)
'    List1.AddItem ""
'    List1.ListIndex = List1.ListCount - 1
'    DoEvents
'
'    ob.DeviceEnabled = True
'    DoEvents
'    List1.AddItem "ob.DeviceEnabled= " + Str(ob.DeviceEnabled)
'    List1.AddItem "ob.Claimed= " + Str(ob.Claimed)
'    List1.AddItem "ob.DeviceName= " + ob.DeviceName
'    List1.AddItem "OpenDrawer: " + Str(ob.OpenDrawer)
'    List1.ListIndex = List1.ListCount - 1
'    DoEvents

' ---------------------------------------------
'    buf = """""=2"
'    buf = "U_=3"
'    buf = "CommunicationErrorCount=4,DrawerGoodOpenCount=5"
'    List1.AddItem "UpdateStt= " + Str(ob.UpdateStatistics(buf))
'
'    buf = ""
'    buf = "U_"
'    buf = "CommunicationErrorCount,DrawerFailedOpenCount"
'    List1.AddItem "ResetStt= " + Str(ob.ResetStatistics(buf))
'
'    buf = ""
'    buf = "U_"
'    List1.AddItem "RetrieveStt= " + Str(ob.RetrieveStatistics(buf))
'
'    List1.AddItem buf

    List1.ListIndex = List1.ListCount - 1
End Sub

Private Sub Command3_Click()
Set ob = Posiflex_CR1

    List1.AddItem "ob.Close()= " + Str(ob.Close())
    List1.ListIndex = List1.ListCount - 1
End Sub

Private Sub Command4_Click()
    Command3_Click
    DoEvents
    End
End Sub

Private Sub cmdRetrieveSt_Click()

    Dim strParam As String
    Dim lLen As Long
    Dim strErrMsg As String
    Dim strXMLPath As String
    Dim strFindXMLPath As String

    strParam = txtRetrieveSt.Text
    strErrMsg = ""
    strFindXMLPath = ""

    With Posiflex_CR1
        .RetrieveStatistics strParam
        If (.ResultCode <> OPOS_SUCCESS) Then
            strErrMsg = "RetrieveStatistics method error." + vbCrLf + vbCrLf
            strErrMsg = strErrMsg + "ResultCode = " + CStr(.ResultCode) + vbCrLf
            strErrMsg = strErrMsg + "ResultCodeExtended = " + CStr(.ResultCodeExtended)
            MsgBox strErrMsg, vbOKOnly + vbExclamation, "CashDrawer"
            Exit Sub
        End If
    End With
    '*** Retrieve Statistics
    Text1.Text = strParam
    
    strXMLPath = App.Path + "\demo.xml"
    'Delete XML file.
    strFindXMLPath = Dir(strXMLPath)
    If strFindXMLPath <> "" Then
        Kill (strXMLPath)
    End If
    'Create XML file.
    Open strXMLPath For Binary Access Write As #1
        Put #1, , strParam
    Close #1
    
    'Opens another window and indicates the information of the XML file.
    RetrieveStBrowser.Show

End Sub

Private Sub Command6_Click()
    List1.AddItem "claim: " + Str(Posiflex_CR1.ClaimDevice(1000))
End Sub

Private Sub Command7_Click()
    List1.AddItem "release: " + Str(Posiflex_CR1.ReleaseDevice())
    DoEvents
    List1.AddItem "State: " + Str(Posiflex_CR1.State)
End Sub

Private Sub Command8_Click()
    List1.AddItem "State: " + Str(Posiflex_CR1.State)
End Sub

Private Sub Form_Load()
    txtRetrieveSt.Text = "UnifiedPOSVersion,DeviceCategory,ManufacturerName,ModelName,SerialNumber,ManufacturerDate,MechanicalRevision,FirmwareRevision,Interface,InstallationDate,HoursPoweredCount,CommunicationErrorCount,DrawerGoodOpenCount,DrawerFailedOpenCount"
    OposSuccess = 0
    OposChExternal = 2
End Sub

Private Sub Form_Unload(Cancel As Integer)
    Posiflex_CR1.Close
End Sub

Private Sub Posiflex_CR1_DirectIOEvent( _
    ByVal EventNumber As Long, pData As Long, pString As String)

    List1.AddItem "DIO: " + Str(EventNumber)
    List1.AddItem ""
End Sub

Private Sub Posiflex_CR1_StatusUpdateEvent(ByVal Data As Long)
    List1.AddItem "SUE: " + Str(Data) _
        + ", de=" + Str(Posiflex_CR1.DeviceEnabled) _
        + ", cl=" + Str(Posiflex_CR1.Claimed)
        '+ ", do=" + Str(Posiflex_CR1.DrawerOpened)
    DoEvents
    'List1.AddItem "wfdc: " + Str(Posiflex_CR1.WaitForDrawerClose(1000, 1000, 1000, 1000))
    List1.AddItem ""
    
    If Data = 1 Then
        lblSTATUS.ForeColor = &HFF&
        lblSTATUS.Caption = "OPENED"
        MsgBox ("Notice! The cash drawer is opened...")
    Else
        lblSTATUS.ForeColor = &H80000012
        lblSTATUS.Caption = "CLOSED"
    End If
    
End Sub


now what?
 
Which buttons are your farm are named what? And which button does what you want done? Just look at the code (in the latest posted) for those buttons and duplicate that.
 
Which buttons are your farm are named what? And which button does what you want done? Just look at the code (in the latest posted) for those buttons and duplicate that.


gotcha! ...man...it's coming together...i hope :D

couple of q's though...

i noticed at the top of the code there is this line

Code:
Object = "{CCB90040-B81E-11D2-AB74-0040054C3719}#1.0#0"; "OposCashDrawer.ocx"
do i still need that somewhere?


also...

you're saying, if i want a click event to pop the register and that happens when click-command1 is initiated, and the code in command one is

Code:
Set ob = Posiflex_CR1
 
    Cls
    List1.Clear
    List1.AddItem "ob.Open()= " + Str(ob.Open(Text1.Text))
    'List1.AddItem "ob.Claim()= " + Str(ob.Claim(1000))
    ob.DeviceEnabled = True
    List1.AddItem "ob.DeviceEnabled= " + Str(ob.DeviceEnabled)
    DoEvents
    List1.AddItem "ob.DeviceName= " + ob.DeviceName
    List1.AddItem "CapMultiDrawer: " + Str(ob.CapStatusMultiDrawerDetect)
    List1.AddItem ""
    List1.ListIndex = List1.ListCount - 1
    If Posiflex_CR1.DrawerOpened = True Then
        lblSTATUS.ForeColor = &HFF&
        lblSTATUS.Caption = "OPENED"
    Else
        lblSTATUS.ForeColor = &H80000012
        lblSTATUS.Caption = "CLOSED"
    End If
    DoEvents
that i just copy and past that info into vba-editor? (i'm going to try it here in a bit, i just have a feeling its a FAIL... :rolleyes:


also...what about these:

Code:
Public Declare Function OpenUSBcr Lib "usbcr.dll" () As Long
Public Declare Function DrawerOpen Lib "usbcr.dll" (ByVal ID As Long) As Long
Public Declare Function CloseUSBcr Lib "usbcr.dll" () As Long
Public Declare Function DrawerState Lib "usbcr.dll" (ByVal ID As Long) As Long
Public Declare Function RetrieveStatistics Lib "usbcr.dll" (ByVal ID As Long, ByVal idx As Long, ByRef buf As Any, ByVal size As Long) As Long
Public Declare Function OpenUSB Lib "usbcr.dll" () As Long
Public Declare Function CloseUSB Lib "usbcr.dll" () As Long
do i need these somewhere in the code?


...man the more questions i ask, the more i feel lost from when i started this msg.



cheers,

b_c
 
Code:
Object = "{CCB90040-B81E-11D2-AB74-0040054C3719}#1.0#0"; "OposCashDrawer.ocx"
do i still need that somewhere?



that .ocx is an "activeX" control that's in the demo folder...


...errr, where does that go now? same, directory as my .accdb file?



b_c
 
You need to create a reference to that active X control in your VBA project. You can do that in the VBA editor menu (under "Tools"|"References").

You shouldn't be looking at code via a regular editor. Much of the code you posted above is not the VBA code but is the definition of some of the objects. Bad thing to mess around with.
 
You need to create a reference to that active X control in your VBA project. You can do that in the VBA editor menu (under "Tools"|"References").

You shouldn't be looking at code via a regular editor. Much of the code you posted above is not the VBA code but is the definition of some of the objects. Bad thing to mess around with.


what editor should i be using?? i just opened it up in notepad...


i've searched all around the internet (and i consider myself quite savvy when it comes to searching the internet), but to no avail. i've seen plenty people asking the same thing, but no one has answered. even my question on this forum is showing up on google, now :D


my guess is that it ties all back to this .txt file that was sent to me from their tech support:

it's the dang "programmer's guide" for pete's sake...
*****************************************************************
* *
* Posiflex CR-4xx5-II Series USB CR DLL v1.03 Programming Guide *
* *
*****************************************************************

The driver required to control the Posiflex USB Cash Drawer
is called "USBCR.DLL". When the Posiflex USB Cash Drawer Test
Program is installed, this driver is stored in folder
"C:\Windows\System" if the default Windows folder is
"C:\Windows". Please preserve this file "USBCR.DLL" in the
system folder for your software to control the Posiflex USB
Cash Drawer even if you want to uninstall the Posiflex test
program.

The driver "USBCR.DLL" provides 7 function calls:
The 1--5 functions are for CR-4XX5-II series to use.
The 6--7 functions are for CR-4XX5 series to use.
The examples of Visual Basic are list below.


1. Public Declare Function OpenUSBcr LIB "usbcr.dll" () As Long
=========
' must be called before calling other functions
' return 0 on success


2. Public Declare Function CloseUSBcr Lib "usbcr.dll" () As Long
==========
' call this function before exiting your program
' return 0 on success


3. Public Declare Function DrawerOpen Lib "usbcr.dll" (ByVal ID As Long) As Long
==========
' return 0 on sending commands successfully, -1 on error
' 'ID' is the drawer number from 0 to 7


4. Public Declare Function DrawerState Lib "usbcr.dll" (ByVal ID As Long) As Long
===========
' return the drawer status
' high nibble is the drawer ID, and
' low nibble is 0 if drawer is open, 1 if drawer is closed
' return -1 on error


5. Public Declare Function RetrieveStatistics Lib "usbcr.dll" (ByVal ID As Long, ByVal idx As Long, ByRef buf As Any, ByVal size As Long) As Long
==================
' return 0 on sending commands successfully, -1 on error
' 'size' is the number of bytes which can be held by 'buf'
' 'buf' will hold the value read from memory in cash drawer
' This function used to Retrieve the device statistics of Unified POS1.8.

6. Public Declare Function OpenUSB Lib "usbcr.dll" () As Long
=======
' must be called before calling other functions
' return 0 on success
' This function is for CR-4xx5 Series to use,
' and it can drive CR-4xx5-II too.


7. Public Declare Function CloseUSB Lib "usbcr.dll" () As Long
========
' call this function before exiting your program
' return 0 on success
' This function is for CR-4xx5 Series to use.
' and it can drive CR-4xx5-II too.


Note : For C++ programs: use __stdcall compiler option


b_c
 
ok...just found this...talks about calling .dll's in excel through vba.

...so it seems you have to "declare" them like the post above (look at the txt next to the numbering).

...then you have to access the .dll via a user defined function. <--errr, what does that mean.


here's the complete webpage >> http://msdn.microsoft.com/en-us/library/bb687915.aspx
You can access a DLL function or command in Microsoft Office Excel in several ways:

  • Through a Microsoft Visual Basic for Applications (VBA) code module in which the function or command has been made available using a Declare statement.
.................................................
Calling DLL Functions and Commands from VBA

You can access DLL functions and commands in VBA by using the Declare statement. This statement has one syntax for commands and one for functions.

  • Syntax 1 – commands


    [Public | Private] Declare Sub name Lib "libname" [Alias "aliasname"] [([arglist])]


  • Syntax 2 – functions


    [Public | Private] Declare Function name Lib "libname" [Alias "aliasname"] [([arglist])] [As type]

The optional Public and Private keywords specify the scope of the imported function: the entire Visual Basic project or just the Visual Basic module, respectively. The name is the name that you want to use in the VBA code. If this differs from the name in the DLL, you must use the Alias "aliasname" specifier, and you should give the name of the function as exported by the DLL. If you want to access a DLL function by reference to a DLL ordinal number, you must provide an alias name, which is the ordinal prefixed by #.
Commands should return void. Functions should return types that VBA can recognize ByVal. This means that some types are more easily returned by modifying arguments in place: strings, arrays, user-defined types, and objects.
...............................................


Calling DLL Functions Directly from the Worksheet

You cannot access Win32 DLL functions from the worksheet without, for example, using VBA or XLM as interfaces, or without letting Excel know about the function, its arguments, and its return type in advance. The process of doing this is called registration.
The ways in which the functions of a DLL can be accessed in the worksheet are as follows:

  • Declare the function in VBA as described previously and access it via a VBA user-defined function.
.....................................
Calling DLL Commands Directly from Excel

Win32 DLL commands are not accessible directly from Excel dialog boxes and menus without there being an interface, such as VBA, or without the commands being registered in advance.
The ways in which you can access the commands of a DLL are as follows:

  • Declare the command in VBA as described previously and access it via a VBA macro.


so, declare the mo's....then call them using a user defined function or a vba-macro.


i think i'm good on the declaration...anyone want to fill me in on the "user defined function" and/or vba-macros?



cheers,

b_c
 
found some text in "learn visual basic 6.0 now"...halvorson


Code:
Function TotalTax(Cost)
    StateTax = Cost * 0.05   'state tax is 5%
    CityTax = Cost * 0.015    'city tax is 1.5%
    TotalTax = StateTax + CityTax
end Function
to call the xx function in an event procedure you would use a statement similar to the following

Code:
lblTaxes.Caption = TotalTax(500)
now what??


:(


would i just need to somehow capture the return value from the register...?



b_c
 
DO NOT program VBA applications using a text editor. Open the Visual Basic editor for your Access project, as I have indicated several times. That is where you do ALL of your VB programming work.

Until you get that concept and put it into practice, there is really no point in dealing with code. Though I will say, the nice cash drawer people sent you a control (the .ocx file) for doing all the "automation". I'm not sure why you need to deal with the DLLs.
 
DO NOT program VBA applications using a text editor. Open the Visual Basic editor for your Access project, as I have indicated several times. That is where you do ALL of your VB programming work.

Until you get that concept and put it into practice, there is really no point in dealing with code. Though I will say, the nice cash drawer people sent you a control (the .ocx file) for doing all the "automation". I'm not sure why you need to deal with the DLLs.


dude...

...i know not to program in notepad...i don't. if you can't help me, i don't need you preaching to me. the .exe file (with it's associated files) was all that was in the OPOScashdrawer "example". the file that tech support sent me "the programmers reference" refers to the DLL...and/so the DLL is what I want to use, and even if i was to use the .ocx file, you still have yet to offer any usable advise.


with that said...

...if you or anyone else wants to constructively help me figure this out, i'm open to learning something new.



b_c
 

Users who are viewing this thread

Back
Top Bottom