Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

VB to read a COM port instead of USB

97 views
Skip to first unread message

Rick Ard

unread,
Oct 2, 2003, 7:33:31 PM10/2/03
to
I have a VB program that reads data from a magnetic strip
reader(MAGTEK) from a USB connection. Works really good.
I bought a reader that reads Magnetic strips and Barcode
info too. The problem is that this reader simulates a com
port only, therefore my program can't read it because it
is set up for USB. I tried using a Com to USB adapter
thinking it would work but learned that the adapters make
the USB look like a com port. My question is what code
can I use to make the VB program look at a Com port
instead of the USB.

Thank You
Rick Ard

Yan-Hong Huang[MSFT]

unread,
Oct 3, 2003, 6:13:25 AM10/3/03
to
Hello Rick,

Thanks for posting in the group.

Based on my experience, in VB, we could use typical Win32 APIs to
communicate with COM port or mscomm32.ocx activex control to talk to serial
port.

For using mscomm32.ocx, please refer to MSDN article:
"HOWTO: Use MSCOMM32.OCX to Transfer Data on DBCS Windows"
http://support.microsoft.com/?id=158008

For using Win32 API, please refer to MSDN topic:
"Serial Communications in Win32"
http://msdn.microsoft.com/library/en-us/dnfiles/html/msdn_serial.asp?frame=t
rue

Does that answer your question?

Best regards,
Yanhong Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
!Content-Class: urn:content-classes:message
!From: "Rick Ard" <ra...@synrdyne.com>
!Sender: "Rick Ard" <ra...@synrdyne.com>
!Subject: VB to read a COM port instead of USB
!Date: Thu, 2 Oct 2003 16:33:31 -0700
!Lines: 13
!Message-ID: <1e95101c3893d$96b76e80$a601...@phx.gbl>
!MIME-Version: 1.0
!Content-Type: text/plain;
! charset="iso-8859-1"
!Content-Transfer-Encoding: 7bit
!X-Newsreader: Microsoft CDO for Windows 2000
!X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
!Thread-Index: AcOJPZa3nzhToopuTASSwCZZt5fatw==
!Newsgroups: microsoft.public.vb.com
!Path: cpmsftngxa06.phx.gbl
!Xref: cpmsftngxa06.phx.gbl microsoft.public.vb.com:39139
!NNTP-Posting-Host: TK2MSFTNGXA14 10.40.1.166
!X-Tomcat-NG: microsoft.public.vb.com
!
!I have a VB program that reads data from a magnetic strip
!reader(MAGTEK) from a USB connection. Works really good.
!I bought a reader that reads Magnetic strips and Barcode
!info too. The problem is that this reader simulates a com
!port only, therefore my program can't read it because it
!is set up for USB. I tried using a Com to USB adapter
!thinking it would work but learned that the adapters make
!the USB look like a com port. My question is what code
!can I use to make the VB program look at a Com port
!instead of the USB.
!
!Thank You
!Rick Ard
!

Rick Ard

unread,
Oct 3, 2003, 4:43:10 PM10/3/03
to
I'll give it a try! Thank you for your quick response!!
>.
>

Dick Grier

unread,
Oct 4, 2003, 3:38:56 PM10/4/03
to
Hi,

You need serial port code (it is easiest to use MSComm). I have code
examples for this in my book. See below. BTW, I use both MAGTEK USB and
serial port readers, and am quite satisfied with their performance.

There is no way to use your USB code with the serial port reader -- they
operate quite differently.

Dick

--
Richard Grier (Microsoft Visual Basic MVP)

See www.hardandsoftware.net for contact information.

Author of Visual Basic Programmer's Guide to Serial Communications, 3rd
Edition ISBN 1-890422-27-4 (391 pages) published February 2002.


Yan-Hong Huang[MSFT]

unread,
Oct 6, 2003, 1:00:57 AM10/6/03
to
Hi Rick,

You are welcome. :)

Thanks for participating the community.

Best regards,
Yanhong Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
!Content-Class: urn:content-classes:message
!From: "Rick Ard" <ra...@synrdyne.com>
!Sender: "Rick Ard" <ra...@synrdyne.com>

!References: <1e95101c3893d$96b76e80$a601...@phx.gbl>
<JmXvDcZi...@cpmsftngxa06.phx.gbl>
!Subject: RE: VB to read a COM port instead of USB
!Date: Fri, 3 Oct 2003 13:43:10 -0700
!Lines: 73
!Message-ID: <0cbc01c389ee$f544e2a0$a001...@phx.gbl>


!MIME-Version: 1.0
!Content-Type: text/plain;
! charset="iso-8859-1"
!Content-Transfer-Encoding: 7bit
!X-Newsreader: Microsoft CDO for Windows 2000
!X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300

!Thread-Index: AcOJ7vVEN9mmroRST4WgG7R/P7NxcA==
!Newsgroups: microsoft.public.vb.com
!Path: cpmsftngxa06.phx.gbl
!Xref: cpmsftngxa06.phx.gbl microsoft.public.vb.com:39165
!NNTP-Posting-Host: TK2MSFTNGXA08 10.40.1.160
!X-Tomcat-NG: microsoft.public.vb.com
!
!I'll give it a try! Thank you for your quick response!!
!>-----Original Message-----
!>Hello Rick,
!>
!>Thanks for posting in the group.
!>
!>Based on my experience, in VB, we could use typical Win32
!APIs to
!>communicate with COM port or mscomm32.ocx activex control
!to talk to serial
!>port.
!>
!>For using mscomm32.ocx, please refer to MSDN article:
!>"HOWTO: Use MSCOMM32.OCX to Transfer Data on DBCS Windows"
!>http://support.microsoft.com/?id=158008
!>
!>For using Win32 API, please refer to MSDN topic:
!>"Serial Communications in Win32"
!>http://msdn.microsoft.com/library/en-
!us/dnfiles/html/msdn_serial.asp?frame=t
!>rue
!>
!>Does that answer your question?
!>
!>Best regards,
!>Yanhong Huang
!>Microsoft Online Partner Support
!>
!>Get Secure! - www.microsoft.com/security
!>This posting is provided "AS IS" with no warranties, and
!confers no rights.
!>
!>--------------------
!>!Content-Class: urn:content-classes:message
!>!From: "Rick Ard" <ra...@synrdyne.com>
!>!Sender: "Rick Ard" <ra...@synrdyne.com>
!>!Subject: VB to read a COM port instead of USB
!>!Date: Thu, 2 Oct 2003 16:33:31 -0700
!>!Lines: 13
!>!Message-ID: <1e95101c3893d$96b76e80$a601...@phx.gbl>
!>!MIME-Version: 1.0
!>!Content-Type: text/plain;
!>! charset="iso-8859-1"
!>!Content-Transfer-Encoding: 7bit
!>!X-Newsreader: Microsoft CDO for Windows 2000
!>!X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
!>!Thread-Index: AcOJPZa3nzhToopuTASSwCZZt5fatw==
!>!Newsgroups: microsoft.public.vb.com
!>!Path: cpmsftngxa06.phx.gbl
!>!Xref: cpmsftngxa06.phx.gbl microsoft.public.vb.com:39139
!>!NNTP-Posting-Host: TK2MSFTNGXA14 10.40.1.166
!>!X-Tomcat-NG: microsoft.public.vb.com
!>!


!>!I have a VB program that reads data from a magnetic

!strip
!>!reader(MAGTEK) from a USB connection. Works really good.
!>!I bought a reader that reads Magnetic strips and Barcode
!>!info too. The problem is that this reader simulates a
!com
!>!port only, therefore my program can't read it because it
!>!is set up for USB. I tried using a Com to USB adapter
!>!thinking it would work but learned that the adapters
!make
!>!the USB look like a com port. My question is what code
!>!can I use to make the VB program look at a Com port
!>!instead of the USB.
!>!
!>!Thank You
!>!Rick Ard
!>!
!>
!>.
!>
!

Rick Ard

unread,
Oct 6, 2003, 7:22:49 PM10/6/03
to

Thank You Dick I will give it a try. My new reader actually does both,
Magnetic & 2D barcode. I'll let you know how it goes! Your experience
will be priceless!!

Thanks
Rick


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Dick Grier

unread,
Oct 6, 2003, 7:50:20 PM10/6/03
to
Hi,

2D has some interesting issues. Did it come with a driver to provide an
API? Usually, I'd think, such a scanner/reader would need to provide an
image that would be interpreted.

If your device actually outputs a serial stream (or the equivalent USB
data), I'd like to know more. What manufacturer and model is it?

Rick Ard

unread,
Oct 9, 2003, 4:41:43 PM10/9/03
to
1.I have a VB program that reads data from a magnetic strip

reader(MAGTEK) from a USB connection. Works really good.
I bought a reader that reads Magnetic strips and Barcode info too. The
problem is that this reader has a COM port only, therefore my program
can't read it because it is set up for USB. I tried using a Com to USB
adapter
thinking it would work but learned that the adapters make the USB look
like a com port. Is there something out there to make the Com to USB
adapter to read it like an USB port instead of a com port. My Laptop
does not have COM ports & my code is set up to read USB connection!

Dick,

Above is a recap of my problem. I did look at your solutions but after
more research it has been determined that we need to stick with the USB
connection. This means that the Mag/2D Reader that is a serial port only
needs to work with my VB code Laptop(which does not contain COM ports)
USB only. Is that possible and will it work somehow??????????

Tired & Confused VB programmer
Rick


Rick Ard
Senior Programmer
Austin Tx
512-266-0665

Yan-Hong Huang[MSFT]

unread,
Oct 10, 2003, 2:12:08 AM10/10/03
to
Hello Rick,

Based on my understanding, now MAGTEK has a USB port. The VB program
communicates with USB port. The new reader has a COM port to your computer
and a USB port to MAGTEK. Now you want to read from the new reader. Also,
you used a COM to USB adapter and try to read it as a USB. Please post here
if I have misunderstood the problem.

I haven't plaied with COM to USB adapter before. Based on my experience, if
it is connected on COM port of your computer, we need to use COM port
communication API to communicate with adapter.

If Mag/2D Reader is serial port only, we can't use USB port programming to
access it. You could try using a USB to COM adapter to see if the program
could make use of it. Also, consulting the manufacturer of Mag/2D Reader
should be a good method to get information on it.

Thanks and please post here if you have any more concerns on it. :)

Best regards,
Yanhong Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
!From: Rick Ard <ra...@synrdyne.com>
!References: <O4gzQSG...@TK2MSFTNGP11.phx.gbl>
!X-Newsreader: AspNNTP 1.50 (ActionJackson.com)
!Subject: Re: VB to read a COM port instead of USB
!Mime-Version: 1.0
!Content-Type: text/plain; charset="us-ascii"
!Content-Transfer-Encoding: 7bit
!Message-ID: <#bkgAXqj...@TK2MSFTNGP09.phx.gbl>
!Newsgroups: microsoft.public.vb.com
!Date: Thu, 09 Oct 2003 13:41:43 -0700
!NNTP-Posting-Host: actionjackson133.dsl.frii.net 216.17.147.133
!Lines: 1
!Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP09.phx.gbl
!Xref: cpmsftngxa06.phx.gbl microsoft.public.vb.com:39295
!X-Tomcat-NG: microsoft.public.vb.com
!
!1.I have a VB program that reads data from a magnetic strip
!reader(MAGTEK) from a USB connection. Works really good.
!I bought a reader that reads Magnetic strips and Barcode info too. The
!problem is that this reader has a COM port only, therefore my program
!can't read it because it is set up for USB. I tried using a Com to USB
!adapter
!thinking it would work but learned that the adapters make the USB look
!like a com port. Is there something out there to make the Com to USB
!adapter to read it like an USB port instead of a com port. My Laptop
!does not have COM ports & my code is set up to read USB connection!
!
!Dick,
!
!Above is a recap of my problem. I did look at your solutions but after
!more research it has been determined that we need to stick with the USB
!connection. This means that the Mag/2D Reader that is a serial port only
!needs to work with my VB code Laptop(which does not contain COM ports)
!USB only. Is that possible and will it work somehow??????????
!
!Tired & Confused VB programmer
!Rick
!
!
!Rick Ard
!Senior Programmer
!Austin Tx
!512-266-0665
!
!*** Sent via Developersdex http://www.developersdex.com ***
!Don't just participate in USENET...get rewarded for it!
!

Dick Grier

unread,
Oct 10, 2003, 2:16:13 PM10/10/03
to
Hi,

You can use a USB serial port adapter. I do this all the time. I prefer
some over others (for example, I have had quite good luck with InPort from
InsideOut Networks, and Quatech adapters, with less satisfactory operation
with IOGear and Belkin -- though the problems with these adapters seems to
be system dependent). Expect to spend about $75 for a good quality adapter,
though you can give one of the lower cost ones a try.

Then, you would use MSComm (or the equivalent) to interface with the serial
port that this adapter provides.

Since this is 2D, do you have an image processing DLL? It really should
provide a serial interface for you (and the decoding). I suppose that the
reader may have built-in decoding. What model is it?

I'd be happy to provide consultation, but at a minimum, I'd have to have the
appropriate hardware (which I don't have; I have only 1D readers of several
different manufacturers). You can contact me at dick_...@msn.com, if you
have interest in this.

Rick Ard

unread,
Oct 10, 2003, 3:35:32 PM10/10/03
to
Thanks I'll let you know how it comes out!

Rick Ard
Senior Programmer
Austin Tx
512-266-0665

*** Sent via Developersdex http://www.developersdex.com ***

frankz...@gmail.com

unread,
Jul 6, 2014, 9:35:34 PM7/6/14
to
2d is more complicated
0 new messages