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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MSComm Object declaration

Status
Not open for further replies.

damann

Technical User
Jul 19, 2000
114
US
Hello all,

Im trying to use the MSComm object to talk through a serial port, but I can't seem to get the thing working right. This is how I declare and use it:

Private PORT As MSComm

PORT.InBufferCount = 0
PORT.CommPort = 1
PORT.Settings = "9600,N,8,1"
PORT.PortOpen = True

This should work, but I keep getting error '91', which says the object variable or with block variable is not set. Can anyone tell me why this is...?

Do I need a statment saying "Set PORT = NEW Something" or something like that? Please let me know...


Thanks,
Damann
 
add the "Microsoft Comm control 6" Component

or are you trying to avoid doing that??

good luck

If somethings hard to do, its not worth doing - Homer Simpson
------------------------------------------------------------------------
A General Guide To Excel in VB FAQ222-3383
The Great Date Debate Thread222-368305
File Formats Galore @ or
 
I've already added that and it makes me use the object, it's not bombing saying object not defined or anything like that. When it sees the first call using the object it cries:

PORT.InBufferCount = 0

When it sees this call it gives me the runtime error '91': object variable or with block variable not set. So I don't know what the hell I'm doing wrong.


Damann
 
You might try:

Set Port = MSCOMM

Assuming MSCOMM is the name of the com control on your form.

But really, you don't need to go through all that. Just access the MSCOMM control directly. ( unless you have a reason to have to assign the control to an object variable )

Robert
 
Ok how do I access the MSCOMM control directly? If this is easier then I'm up to try it...
 
I think I got it... Thanks all!!
 
my control is called MSComm1. this is how i use it. you have to set its properties as well.

MSComm1.CommPort = 1
MSComm1.PortOpen = True
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top