Page 1 of 1

I/O Handling and VBA

Posted: Thu Sep 25, 2008 1:32 pm
by IDontBelieveIt
Does anyone here know how to set about I/O handling within VBA (Excel in particular)?

In the old days you had to compile handlers or write handler in assembler and merge the .OBJ file but wandering if it is possible to handle directly these days.

What want to do is to use a Bar Code hand scanner plugged into one of the USB ports and read the ASCII string that they sends up directly into a VBA application.

Cheers

Posted: Thu Sep 25, 2008 4:22 pm
by Hoovie
like you said, in the olden days (Before Windows), you would use something like MASM to write a routine to read the data directly from the IO Port.

I would guess (and it is a guess) that you need to speak to the device driver rather then the device or port itself - maybe by finding the PID (that could be visible in the Device Manager or probably more easily in the .inf file) and referencing that.

I dusted off my Visual Basic 4 book and looked at the index - no entries for hardware, drivers or even I/O except for user I/O (keyboard/display!).

personally not done any machine code writing since 1984 (diagnostic noddy apps for Prime Computer bench repairs :roll: - any use? :lol: )

Posted: Thu Sep 25, 2008 5:24 pm
by IDontBelieveIt
Thanks for that Hoovie, I rather suspected what you have said (sadly).

Indeed it may not be possible at all other than compiling the application, if so I wont bother. :cb

I remember Prime Computers (and a host of others). Well at least I have been writing in assembler more recently than you, last time I think was around 1995. I hated the old 'heap memory' management side of 86 coding love normal linear machines.

I will continue to explore, thanks again Hoovie...

Posted: Thu Sep 25, 2008 5:32 pm
by IDontBelieveIt
Ah!! Just had a thought, you inspired me Hoovie (a wee dram also assisted).

I have just recalled that you can run other application programs for within VBA (did in back in 1997). The only 'problem' back in those days was to pass information between the other program and VBA.

So what I did was to do it using files. Within VBA I would search the entire system disc for a specific file and if I found it deleted it - all easy with VBA. I would then pass control from VBA to another applications and this application would, just before it closed would write the file previously cleared the I would extract information from within VBA again straightforward.

And so if I get a bar code hand scanner that writes a file, rather than send up an ascii string using a supplied utility then Bob's your Uncle I will use the same technique. Eureka !!

Thanks again Hoovie you have pushed me in the right (I hope) direction.

Posted: Thu Sep 25, 2008 5:37 pm
by Hoovie
yup - that would probably work (I recall using that kind of technique for making interactive DOS batch files and Basic/QBasic)

could be interested in the future in getting this routine from you (always fanced making a Library DB using a barcode scanner to read the ISBN code)

Posted: Thu Sep 25, 2008 5:53 pm
by IDontBelieveIt
Will do Hoovie, it may be a while as it is a background task at work. I have the Wasp bar code generating software and a bar code reader but its not a stand-alone hand held unit so need to order one - which will be a task in itself - to find one that does as I described above that is, bound to exist.

Regards

Posted: Wed Oct 08, 2008 10:10 am
by kenjewell
IDontBelieveIt wrote:Will do Hoovie, it may be a while as it is a background task at work. I have the Wasp bar code generating software and a bar code reader but its not a stand-alone hand held unit so need to order one - which will be a task in itself - to find one that does as I described above that is, bound to exist.

Regards
Did you ever sort this out?

I had similar task using VB6 a couple of years ago, where I needed to use the parallel IO port for input capture. I ended up writing a DLL in VC++ for VB to access the port as a module.

Just a thought but maybe the barcode scanner has an API that can be used for further development into other applications then you could easily access it from VB or VBA?

It's worth checking with the manufacturer.

Regards,
KJ