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

Sub or Function not defined

Status
Not open for further replies.

mspope

IS-IT--Management
Aug 19, 2002
123
US
I'm new at this... I'm using VB6 to create a formless console application.

I have Sub Main in Module1
I have a UserControl form (Named Comm) with MSComm1 embedded (Microsoft Comm Control 6.0) as I wish to do some serial port communications.

In the usercontrol I have a sub routine:

Public Sub OpenPort()
MSComm1.PortOpen = True
End Sub

In the main sub I call OpenPort:

Public Sub Main()
Call OpenPort
End Sub

When I run this, I get "Sub or Function not defined" and "Call OpenPort" is highlighted.

I don't understand why I get this error....

 
You need to prefix the call with the form name, I think thats all the problem is.

Call Comm.OpenPort
 
Thanks, I tried that earlier without luck. Also I can't even do an MSComm1.OpenPort=true from sub_main. I get a "Variable not defined" error. Thou I can call up the MScomm1 property sheet.
 
You last prob is because you should have .PortOpen not OpenPort. But you still need the form reference ie Comm.MSComm1.PortOpen=true. I did a quick test, I get the same result as you until I add the form identifier then it works ok.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top