Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

MScomm.portopen problem

Posted on 1999-07-22
5
Medium Priority
?
536 Views
Last Modified: 2013-12-25
I admit I am new to programming comms - but this isn't exactly rocket science!

I have been given this gizmo to communicate with which should be straightforward (It comes with a DOS program which needs to be rewritten in Win32). I am running Win95, VB5 (SP3).

I have 2 comm ports on the PC with this gizmo plugged into com1 I find that the the command "mscomm.portopen = true" gives me an error claiming "port is already open" (Err 8005) yet when I write to it it says "operation only valid when port is open" (Err 8018). If I break the program and look at the value then sure enough mscomm.portopen IS false!!

If I change the mscomm.commport to com2 then there is no such problem... ie. port starts off closed, then it is opened, then it is written to.

I want to keep it in com1 for now - and at least offer a choice. But the DOS program I am converting is hardcoded to com1.
0
Comment
Question by:Upland
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 2

Expert Comment

by:alokanant
ID: 1495555
Why don't you check the value of mscomm.portopen before setting it to true.
You can do this at several places of the program, to find the exact instance where the value becomes true.

hope this helps.
0
 
LVL 2

Expert Comment

by:alokanant
ID: 1495556
There are following possible reasons, please check them out one by one, besides the comment given by me -
1> Check whether the address assigned by the software to Com Port 1 is correct or not, this means that your software might be setting the parameters of Com port to address of the second comm port.
2> There may be a problem in the Com Port 1. You can check this by connecting this to some other device.

hope this helps.
alok.

0
 

Author Comment

by:Upland
ID: 1495557
alokanant

Thanks for the reply.....

As I mentioned in the question I HAVE done a break and checked it. Even if I break on the line "mscomm.portopen = True" and look at the value of mscomm.portopen before the line is executed, it tells me it is False - yet as soon as I execute that very same line, it gives me the error about it being already open!

In your answer, I am not sure what you mean by Point 1. According to windows, the address of com1 is 3F8 and com2 is 2F8. This cannot be affected from within VB where you simply pass 1 or 2 to the functions.... or have I missed your point?

In response to your Point 2, the DOS program supplied works just fine on either port.
0
 

Accepted Solution

by:
rockie earned 200 total points
ID: 1495558
I have had this same problem with a program,
and mscomm1.portopen said false when I stepped it through.
And as simple as it sounds it is another program or device not associated with your visual basic program is more than likly grabbing the port.  here are some things to try
1.cntrl + alt + del   -   and end all tasks except for     explorer and systray  then try it if that don't work run it on another computer, if you can not run it on another computer boot up in safe mode(the reason why in safe mode you might only see on device on com1 in normal mode but in safe mode you never know how many are realy trying to use that com port, remove them all if there are any "ghost devices") remove your com port and any devices that are using it in your device manager. shut down go into your system bios disable com 1.  Exit save the changes and reboot.  let windows detect the com port and the device you removed on it.  Then go back to your device manager and disable this device ----- try it again after ending all tasks except explorer and systray.

the problem your having dosen't sound like a visual basic problem, but instead a computer problem.
best of luck
rock

0
 

Author Comment

by:Upland
ID: 1495559
Rockie,
Yes... you are absolutely right! The DOS program which I had run did not give up control of the port... as soon as I closed the DOS box the port was freed.
I still find it annoying that it said it was False when it was actually True. Anyway... it is fine now thanks!
Chris
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

660 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question