473,412 Members | 4,519 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,412 software developers and data experts.

COM open/close problem

the following code works most of the time, but sometimes it fails.
Anyone got an idea? It will pass the IF statement (port is open) but
fail to set the port closed.

If MSComm1.PortOpen Then
MSComm1.PortOpen = False
End If

It also fails in the other direction.

If Not MSComm1.PortOpen Then
MSComm1.PortOpen = True
End If
Jul 17 '05 #1
2 2859
Have you checked to assure that the .CommPort value hasn't
been accidentally changed? If it has, you're closing the
wrong port. :)

"Bill" <wi*****@hotmail.com> wrote in message
news:ee**************************@posting.google.c om...
the following code works most of the time, but sometimes it fails.
Anyone got an idea? It will pass the IF statement (port is open) but
fail to set the port closed.

If MSComm1.PortOpen Then
MSComm1.PortOpen = False
End If

It also fails in the other direction.

If Not MSComm1.PortOpen Then
MSComm1.PortOpen = True
End If

Jul 17 '05 #2
I'm not sure how the .CommPort could change between the IF statement
and the assignment statement. In addition, when it fails, I can hover
over the variable and it tells me that the port is open (in the first
case) or closed (2nd case), so the assignment statement should work,
but still fails.

If my memory is correct, I have even set the program back to the IF
statement and reexecuted the lines and it still passes the IF
statement but still fails the assignment statement.

"CajunCoiler \(http://www.cajuncoiler.tk\)" <ca*********@totallyspamless.cox.net> wrote in message news:<V8fPa.553$N%3.372@lakeread01>...
Have you checked to assure that the .CommPort value hasn't
been accidentally changed? If it has, you're closing the
wrong port. :)

"Bill" <wi*****@hotmail.com> wrote in message
news:ee**************************@posting.google.c om...
the following code works most of the time, but sometimes it fails.
Anyone got an idea? It will pass the IF statement (port is open) but
fail to set the port closed.

If MSComm1.PortOpen Then
MSComm1.PortOpen = False
End If

It also fails in the other direction.

If Not MSComm1.PortOpen Then
MSComm1.PortOpen = True
End If

Jul 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Venkat | last post by:
Hi, I am using ifstream to open a file read it and then close it. Sample Code ------------------- ifStream inFile("file1.txt"); ....... .......
13
by: ldan | last post by:
Hi everybody, I would not consider myself an expert in javascript - but so far whatever I know, helped me reaching my goals. Recently I started to experience a lot of javascript errors related...
5
by: blue | last post by:
We often get connection pooling errors saying that there are no available connections in the pool. I think the problem is that we are passing around open readers all over the place. I am...
3
by: Lars Netzel | last post by:
Hey! I have problems with timeout cause of problems obtaining a pool in the SQL server.. and I guess It's because I might have forgotten to Close some sqlConnection somewhere.. so I search thru...
5
by: Saulot | last post by:
Hi, Facing a big problem. In my Default.aspx page, I open a connection with ma Sql Server DataBase through my objects framework (A "SetDefaultConnectionString" property which open my...
6
by: blue875 | last post by:
Hello helper people who are smarter than me: I have a form that needs to submit multiple queries to different tables during one Sub's execution. Some sections are as simple as: 1| With rst 2|...
20
by: fniles | last post by:
I am using VB.NET 2003, SQL 2000, and SqlDataReader. As I read data from tblA, I want to populate tblB. I use SQLDataReader for both tables. I do not use thread. When I ExecuteReader on tblB, I...
5
by: Usman Jamil | last post by:
Hi I've a class that creates a connection to a database, gets and loop on a dataset given a query and then close the connection. When I use netstat viewer to see if there is any connection open...
6
by: =?Utf-8?B?RyBIdXN0aXM=?= | last post by:
I am creating a new MS Access DB in code, which works fine. I then try to open it & set a password. I keep getting an error that the DB is already open by my machine's Admin account. In reality it...
2
by: existential.philosophy | last post by:
This is a new problem for me: I have some queries that open very slowly in design view. My benchmark query takes about 20 minutes to open in design view. That same query takes about 20 minutes...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.