Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MSCOMM VB Component 1

Status
Not open for further replies.

Mighty

Programmer
Joined
Feb 22, 2001
Messages
1,682
Location
US
Hi Folks,

I haven't written anything in VB for about 8 years so I am very rusty. I need to create an application that writes/reads to a COM port on the local machine. I had attempted to start to do this in VB.NET. However, i am new to that and I just don't have the time to learn how to use it as I only have a week to write this.

So, when time is short, stick to what you know. As the local machine has IIS installed, I plan to write an ASP application (I KNOW ASP WELL!!!) and then try to find a VB component that can read/write to the serial port. Can anyone point me to a good source for such a component or are they easy to write. It's nothing complicated - I just need to be able to read and write to an electronic balance connected to the com port.

Thanks.

Mighty
 
I've done my first bit of MSComm programming this year and found it fairly straightforward. There are plenty of examples within this forum by far better coders than me that really helped, and if you can locate / have the programming / technical manual for the connected device you should have no problems.

HTH

TazUk

[pc] Blue-screening PCs since 1998
 
VB6 comes with the Microsoft Comm Control. Just select "Project / Components" and check "Microsoft Comm Control 6.0". Drop one on a form and it gives you what you need to work with a COM port.
 
Golom,

Thanks for the tip. I want to be able to just create a DLL that I can register on a machine and call from an ASP application. If i select ActiveX DLL as the project type when I start Vb6, how do I add the MSComm component as it won't let me drop it into the development window???

Mighty
 
hmm.. not something ive ever tried, but can you not just use

dim Com1 as MSCOMM



If somethings hard to do, its not worth doing - Homer Simpson
 
Maybe this will help, its out of a program I wrote:

TO RECEIVE DATA:

Private Sub MSComm1_OnComm()
'-- RECEIVE DATA

Select Case MSComm1.CommEvent

Case comEvReceive

'MsgBox ("rec'd")

strComm1input = strComm1input & MSComm1.Input

End Select

End Sub

I would then check strComm1input for the ETX character or whatever signaled the end of the data. To send data just use : MSCOMM1.output = "THIS"

I declared these in a module for my start, stop, ack, nak, field seperator characters, etc.

Public Const STX = 2
Public Const ETX = 3
Public Const ACK = 6
Public Const NAK = 21
Public Const FS = 28
Public Const Q = 34

Hope this helps. Dont forget to set your stop bits, port, parity, etc.

Shannan

 
Mighty,

You can open an ActiveX DLL and add a form. After you add the form do a "Ctrl t" This will bring up the components dialog box. Choose Microsoft Comm Control 6.0. You can drag the control from the tool box to your form. When the dll starts just make sure the form is loaded but not shown. I believe this code can go into your initialization function. Now you have the control, MSComm1, to work with in your class.


HyperEngineer
If it ain't broke, it probably needs improvement.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top