For Programmers: Free Programming Magazines  


Home > Archive > Visual Basic > December 2005 > MS Comm input









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author MS Comm input
zeman

2005-12-16, 3:55 am

Hi all,
I have a machine (switch or router) connected to my COM port.
I need to get the input from that machine, such as the hostname, or any
other character.
I want to WAIT for that character.
How do i do it?

thanks!

Dick Grier

2005-12-16, 6:56 pm

Hi,

Add MSComm to a form.

In the Form_Load event:

With MSComm1
.Settings = "9600, N, 8, 1" 'for example
.CommPort = 1 'for example
.RTSEnable = True
.RThreshold = 1
.PortOpen = True
End With

Private Sub MSComm1_OnComm ()
Static Buffer As String
Buffer = Buffer & MSComm1.Input
If InStr(Buffer, someterminatingcharacter) Then
Process Buffer 'you write this code
Buffer = "" 'don't forget this line to clean up
End If
End Sub

or variations.... For lots more information, you may be interested in my
book. See below.

Dick

--
Richard Grier (Microsoft Visual Basic MVP)

See www.hardandsoftware.net for contact information.

Author of Visual Basic Programmer's Guide to Serial Communications, 4th
Edition ISBN 1-890422-28-2 (391 pages) published July 2004. See
www.mabry.com/vbpgser4 to order.


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com