Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    Visual Basic




Flushing VB6 MSComm1 Serial Buffer...


Hi. I am completely desperate!!!! I have tried the following to try and clear out the MSComm1 buffer with no success. Of course, to the best of my knowledge, I had placed them in the correct sequence/location in the application:

Do
temp = Main.MSComm1.Input
Loop While (Main.MSComm1.InBufferCount <> 0)

MSComm1.PortOpen = False

MSComm1.RThreshold = 0

MScomm1.DTREnable = false

What else can I do to prevent premature triggering MSComm1_OnComm() due to uncleared RS-232 received buffer? Thanks.




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Flushing The Keyboard Buffer?
I know I asked this question in the past but it doesn't show up with the forum search.

Ah Well.

Is there a windows API to flush the keyboard buffer?

I need to kill keystrokes that are pumped in ahead of time by the user.

Thanks!

~T

Flushing RS-232 Input Buffer...
Hi. I am running a VB6 application which is "bugged" by having "extras" in the buffer. I know this since I am using MSComm1_OnComm() serial input to trigger my application. This is done with:

Mscomm1.RThreshold = 2.

If not used for a while, the appication runs great - on the first run. After that, the application would trigger prematurely.

What is the best way - coding or VB built-in function(s) - to completely empty out the RS-232 input buffer before starting the next run? I have used the following line prior to starting up the next process:

MSComm1.InBufferCount = 0 ' clear serial buffer

This did not help. What should I do?

Thank you for your help.

MScomm Buffer Flushing Or Something
Here's my situation. I am sending communication to some hardware and expecting a result. Somewhere else in my software I store the results of these hardware queries in an SQL database. My code runs all the time 24/7. It works for weeks at a time and then one morning I will look in the database at find that the values are off by one column. It turns out that I am now getting answers to the previous question instead of the one that I just asked. So it seems to be a buffer problem where the input buffer of the com port still had the last answer stored and then the current answer gets stored behind it in the buffer. So I'm wondering if there is any way to clear the buffer? Here is the code of interest.


VB Code:
Private Sub class_initialize()    Set commLink = New MSComm    If commLink.PortOpen = True Then         'double check to avoid error if this sub re-called       commLink.PortOpen = False    End If    commLink.CommPort = 1                    'portnumber    commLink.Settings = "9600,N,8,1"         '9600 baud, no parity, 8 data and 1 stop    commLink.InputLen = 1                    'Set INPUT to read ONE char    commLink.RTSEnable = False               'disable    commLink.DTREnable = False               'disable    commLink.Handshaking = comNone           'for 3 wire connection    commLink.PortOpen = True    End Sub Private Function sendCommunication(command As String) As String        inputString = ""    timeoutTime = DateAdd("s", TIMEOUT, Now)    commLink.Output = command & vbCr & vbLf            While Right$(inputString, 1) <> vbLf        If Now > timeoutTime Then            sendCommunication = "Timeout"            Exit Function        Else            inputString = inputString & commLink.Input        End If        DoEvents    Wend     sendCommunication = Left$(inputString, Len(inputString) - 2) End Function

Flushing The Mouse Buffer
I have an MDI application with a child form showing. When I then pop up a modal form, such as a file open dialog box, when the user double-clicks a filename it is selected, the dialog box goes away but then a click is registered by the child form underneath where the mouse happens to be, possible starting another action on the child form.

I need a way to flush any pending mouse clicks when I get back to the child form so this "bleed through" doesn't happen. I am hoping that there is an API call that will do this... Do any of you know of one, or some other method to fix this problem?

(I have tried disabling the child form before popping up the modal form and then re-enabling it a second after closing the top form. This kind of works but it causes the MDI form to disappear behind any other application that is running for a second and then re-appear. Not good!)

Problem With Mscomm1. Cannot Receive The Entire Buffer.
Greetings everyone...

I have a question.

I connected to computers using modem to modem connection. I used the mscomm1 control. The problem is, when I send a message from one computer to another, the receiving computer will receive only the last character(s) after the eight characters.

For example, if I send the phrase "How are you?" from the sending computer, the receiving computer will receive only the phrase "you?". This is the code of the receiving computer:

Sub mscomm1_OnComm()
       dim InBuff as string
       Select case comEvReceive
           Inbuff = mscomm1.input
           text1 = inbuff
       Select case ....

       End Select
End sub

Can anybody give me any idea how to fixe this problem.


Best regards...


Yura...

Stripping Escape Characters From Input Buffer Mscomm1
How do I clear the input buffer after a certain string of bytes so that it will start over again and look for the next string of bytes?

Problem is that the buffer splits up the escape string because of the 14 byte limitation so that the do-loop sequence does not match.
My do-loop sequecnces look for the escape sequence bytes in an exact sequence before stripping them.

The debug window below (Immediate Window in VB6) shows the buffer splitting up the sequence.

Receive - Wel
Receive - cometo
Receive - TSU HOMETD[9;
Receive - 34HCraft Inter



I would like it to read like the following...unless there is a better way.

Receive - 
Receive - 
Receive - Welcome
Recieve - 
Recieve - to
Receive - TSU HOMETD
Recieve - 
Recieve - Craft Inter



' Eliminate Escape Sequence.
Do
i = InStr(Data, Chr$(27) & Chr$(91) & Chr$(50) & Chr$(74))
If i Then
Data = Left$(Data, i - 1) & Mid$(Data, i + 4)
End If
Loop While i

Do
i = InStr(Data, Chr$(27) & Chr$(91) & Chr$(53) & Chr$(59) & Chr$(51) & Chr$(56) & Chr$(72))
If i Then
Data = Left$(Data, i - 1) & Mid$(Data, i + 7)
End If
Loop While i

Do
i = InStr(Data, Chr$(27) & Chr$(91) & Chr$(53) & Chr$(59) & Chr$(51) & Chr$(56) & Chr$(72))
If i Then
Data = Left$(Data, i - 1) & Mid$(Data, i + 7)
End If
Loop While i
'to the

Do
i = InStr(Data, Chr$(27) & Chr$(91) & Chr$(54) & Chr$(59) & Chr$(51) & Chr$(57) & Chr$(72))
If i Then
Data = Left$(Data, i - 1) & Chr$(32) & Mid$(Data, i + 7)
End If
Loop While i

Any suggestions?

Serial Comm/mscomm1 Making It More Robust
I have a crude input routine working, but I know from experience the device I'm talkin' to is likely to fail by high voltage arcing, which has a tendency to screw up the serial communications.
Here is my input routine:

Public Function inputHVPSInputString() As String
Dim str As String
Dim t1 As Single
t1 = Timer

' MsgBox " About to input string "
Do
DoEvents
If MSComm1.InBufferCount > 0 Then
str = str & MSComm1.Input
Else
MsgBox " Empty read buffer "
End If
Loop Until InStr(str, Chr(3)) Or Timer - t1 > 1

If InStr(str, Chr(3)) > 0 Then ' Found End of Text char, good data rec'd
HVPSOpenClosePortTimer.Enabled = False
HVPSCommReceiveTimer.Enabled = False
inputHVPSInputString = str ' return found string
Else
MsgBox " inputHVPSInputString() didn't find End of Text char in this data recd = " & str
HVPSCommReceiveTimer.Enabled = False
End If
TbxHVPSRecdDisp.Text = str

On Error Resume Next
inputHVPSInputString = str

End Function

The comm receive timer is turned on in the output routine, setup to about 2 seconds. All commands and responses are short, like less than 50 chars. It does send/receive a checksum with each sequence. In addition each command is echoed. Should I be evaluating the checksum in all rec'd strings ? The echode command ? Should I be using oncomm and Evreceive from the MSCOMM properties ? How can I make this routine more robust so it will withstand the arcing problem which is almost sure to happen a few years down the road...
BTW: This is actually a USB port connection and runs at 115k baud, N, 8, 1 setup.

Problem With Sending Data To Serial Port Using Mscomm1
hi there
got a question concerning serial port
basically i need to send value 42 to an electronic board to get a receive data from serial but unfortunatly nothing happen
so how do u normally send data like that
is it just
mscomm1.output = "42" ??? i try that and it did not work please helps!!!!!!
ps. i also try mscomm1.output = "31 34" (as in ascii no and still not work!!!)
so do i need to add any other command to it when sending
many thanks
sun

How Long Is The Buffer In Serial Communication?
Hello friends,

I'm using this to read RS232:
Buffer = MSComm1.Input

Is there a way read only to a curtain character? (crLF)

I'm sending request with the MSComm1.Output and clearing the Buffer before every request but the Buffer are not receiving the same amount of data every time.

Sometimes: 123.2 bar
Sometimes: r 123
Sometimes: ar 123.
etc.

I want to make sure that I capture the whole message in the buffer.

Thanks for you help in advance!

Marcus

How To Clear The Input Buffer Of Serial Communication Port?
Hi,

I write a vB program to communicate with AT89C51 microcontroller via serial communication port. When I first run the program, the communication between the VB program and the AT89C51 works as expected. However, when I exit the program and then execute it again (after few seconds), I found that the first few bytes received from AT89C51 are not correct. I suspect that the input buffer of the serial port still has something after exit from the program and the data in the input buffer causes the first few received bytes of next program excecution to be not correct. Therefore, I think of clear (flush) the input buffer at the start of each program execution. Please advise how could I do that.

TQvM

How To Clear The Receive Buffer Of Serial Communication Port?
Hi,

I write a vB program to communicate with AT89C51 microcontroller via serial communication port. When I run the program first time, the communication between the VB program and the AT89C51 works as expected. However, when I exit the program and then execute it again (after few seconds), I found that the first few bytes received from AT89C51 are not correct. I suspect that the receive buffer of the serial port still has something after exit from the program and the data in the input buffer causes the first few received bytes of next program excecution to be not correct. Therefore, I think of clear (flush) the receive buffer at the start of each program execution. Please advise how could I do that.

TQvM

Accessing Or Managing A Harware Buffer Like CD Writer Buffer
Respected Members,
I like to know about, how can we access or manage a hardware buffer area using vb 6.0. Actually I mean A cd writer buffer. Is it is possible to read data from H/w buffers.
Faithfully
Sandeep Thomas

Buffer Or Not 2 Buffer? PLEASE READ, EVEN IF YOU DON'T KNOW BUFFERS.
Some books I have been reading, which date back to 98, say that when passing data from the business teir to the UI you shud use a buffer, and then it goes into loads of programming techneques to deal with buffers. Is there any need?
I know if the LAN is slow then a buffer may be a good idea, but with todays computers, servers and LAN connections, is there any need to use buffers?

Flushing The IE Cache
I used to have some code for flushing the MSIE cache but I can't find it on MSDN any more. Any ideas?

Flushing To Disk
I have a VB program that writes text to a file. I need to cater for a case of a power loss very shortly after the file is closed.
Testing that, I hae found that after rebooting sometimes the file is filled with nulls or even does not exists.
Is there some API call i can use to force flushing the file to disk?

thanks

File Flushing Neccessary In VB6?
When writing and reading sequential files in VB6, is it necessary to flush files somehow to guarantee that files always get written immediately when closed? I am seeing behavior in my code that suggests that files are not always being written immediately following the close statement.

Flushing Excel Processes ....
Is it possible via code to remove "Excel" processes ? and if so does anyone have said code ?

TIA ...

Flushing TCP/IP - Expert Help Needed.
Hi,
I am working on a project for school and need a little help. I need one of my functions to be able to flush tcp/ip and re install it. or set the tcp/ip settings in registry to dynamic, also if there is any ways to detect errors from internet explorer through API, say internet explorer has been launched and was not able to load a web site or outlook express was launched but was not able to send mail.

any help would be appreciated. All I need is say a reference or name of a Book that would have advanced VB programming. I am mainly a self learner.

TIA

Flushing Disk Cache
Hi,

I am struggling with writing into a textfile and immediately read out of this file with the TRANSFERTEXT function. I'm using VB in MS Access 97.
Every now and then it happens, that the data is not written into my file, when I already want to read out of this file.
Is there a way to ensure, that the data is already written to the file or force the OS to flush the cache?

TIA
Bernd

Flushing USB Storage Device
someone know how I can flush an USB Storage Device>?
so when I disconnect it
it will automatic flush the memory

Flushing Text File
I used shell command following by a program name to be executed. when executed, this program creates a text file, which is opened in the next statement after shell command.

Shell <mycommand> ' this command creates a text file
Open myfile.txt for input as #1 ' to open the text file created earlier

After the shell command is executed, the next Open command should open the text file. But the problem is that the Open command is executed before the text file is flushed to the disk and therefore I am getting File Not Found error.

To correct this problem, I inserted a dummy for...next loop so the file is flushed during this time

Shell <mycommand> ' this command creates a text file
For x = 1 to 1000000
next
Open myfile.txt for input as #1 ' to open the text file created earlier

Now the file opens correctly. Is there any way to make sure that the open command is executed only after the text file is flushed to the disk.



Edited by - TrinTrin on 4/30/2008 8:33:57 AM

Flushing Keyboard And Mouseclicks From VB, Can You?
Hello all,

At my present location, we have industrial PCs running on old 486 and P233 class machines which talk to another machine of the same class. There are several forms that are displayed depending upon how the user naviagate through the system. The problem that I am seeing or they are seeing in the field is that people will press a button and expect the form to transition quickly. Depending upon the form certain RPC are made and house keeping is done. Well, if the process takes more than a few seconds they perceive this as the button never registered they clicks so they click the button several times. Well, when the form finally finishes and loads the new form the additional clicks transfer to the next form that is displayed. If there is a button in the same locations as where the clicks were registered it will trigger a click for that button. This affect is not desired and I am trying to figure out a nice approach to solve this problem. I have tried using a boolean like


private Sub Btn1_Click()

if Not m_bFormNotActivatedYet then
' Perform my action now
End If

End Sub


private Sub Form_Activate()
' Last code to execute in Activate
m_bFormNotActivatedYet = false
End Sub

private Sub Form_Load()
' First Statement in Load
m_bFormNotActivatedYet = true
End Sub




This does appear to work. Next I used a timer to help solve this problem, but they don't like the side affect that is introduces. Which is they is a slight delay before they can press a button on the new form and the action takes place. So what I am looking for is some how to flush all keyboard and mouse click events from the que. Is there such a way to do this? I was always thinking of subclassing the form, but I was checking to see if there is another solution to this problem. Thanks

Mark

Immediately Flushing Buffers To Disk
I have this 'small' problem with Windows 98.
I have an app which needs to interact with another app and it's time critical.
It writes stuff to an ini file and then tells the other app (which I didn't wrote) to read the changed values.
On 2k,XP and 2k3 it works like a charm, but on Win98 it doesn't and it still reads the old values.
However, WritePrivateProfileString returns non-zero (means ok).
So the solution till now is that when the user has Win9x that it throws a messagebox with a message that everything wend ok when the return value is non-zero. And that seems to force my app to write the buffers to disk before telling the other app to read its new settings.
Still with me? Good
I've tried to force to flush the diskcache but no luck so far. And already then i ran out of ideas what to do, instead of throwing a messagebox. You'll have to agree with me that that's an ugly way to solve things.
Any help would be appreciated

Flushing TCP Stack Using Winsock - Urgent
Hello,

I have a huge problem.

Here's what's happening
I wrote a client and a server app.
What happens is that I sent some data to client, then pause, then send some more data, what I noticed however is that if I just send "ABC" with out any VBCRLF it does not actually send it unless I send more data or send break line. Is there anyway to force winsock to send just "ABC" ?

Thanks

Updating Access Table Problem With Flushing Cache
Hi, I am having problem updating the access table from my vb program.
Pseudocodes below:

Dim rs As ADODB.Recordset

firstly I set rs to point to access table "ABC"

secondly,
loop through a text file (CSV)
read each line
rs.addnew
update each field of rs with textfile,
end of loop

third, issue following statement:
rs.update (updates the ABC table with rs)

Then, when I want to insert into another table say DEF with records from table ABC, "insert into DEF select * from ABC", my problem is sometimes it worked (there is data in DEF), but sometimes it doesn't work (there is no data in DEF).

I am lost. Could you please help?

Flushing Data On Hard Disk With Jet 3.51 In Shared Environment - Seek Urgent Help
Flushing Data on Hard disk with Jet 3.51 in shared environment - Seek urgent Help

MSCOMM1 In VB 6
Hi there

I have what I think is a very simple problem which I was hoping someone could help me with. I have a RS232 hardware device which turns different relays on and off. I have connected to the hardware with Telnet and it works just as it should. For example if I send "RFF" all the relays turn on and if I send "R00" all of the relays turn on.

I have tried to create a VB program so that I can start to control the hardware as I want. The program consists of an on and an off button. Clicking on either button should send either "RFF" or "R00". However nothing seems to work :-(

The program has very little code in it -

Form load -

MSComm1.Settings = "9600,N,8,1"
MSComm1.CommPort = 1
MSComm1.PortOpen = True


On Button -

MSComm1.Output = "RFF"


Off Button -

MSComm1.Output = "R00"

The com port is defently 1 as this is what is used in Telnet but I have tried it with different com ports just in case. The device should work with - 9600,N,8,1 as this is what is used when using Telnet.

Just wondering if anyone has any ideas?

MSComm1 Help
I'm trying to read in strings of hex values, 12 bytes in total (ex. 01 09 0C 96 38 F0 07 00 00 00 00 5C). I want to be able to take these strings, ignore the first three bytes (they're always the same), and compare them so that they can be used in IF statements (ie IF "hex string" comes in, send out value). The deal is that I have very little Visual Basic experience. If someone could give me a few pointers it would be greatly appreciated.

Mscomm1
hello all, i am facing some problem with com port, since i am new to vb6. the oncom event is not working corectly
10x for help

About MSComm1
hi, how to create an event like this one


VB Code:
'Form LoadPrivate Sub Form_Load()StatusBar1.Panels(1).Text = "Not Connected"MSComm1.Settings = "9600,O,8,1"MSComm1.CommPort = 1MSComm1.RTSEnable = TrueMSComm1.DTREnable = FalseMSComm1.PortOpen = TrueEnd Sub


im creating a program that needs nokia mobile phones... when i run the software i want the status bar display connected if i remove the cable from comport i want the status bar dispaly not conneced...

how to do this?

thanks..

Mscomm1
hi friends,

i am sending some commands to a port and the port responds with "0" if it was successful, so i want to wait till i receive "0" for few minutes before sending any more commands to the port. if suppose it does not respond for say 5 mins then i would like to give a message saying that the insturemnt on that port is not working properly..

the comands i am sending is
MSComm1.Output = "13 FF"
MSComm1.Output = "15 00"

before sending the second command i want to receive "0" from the port, else i dont want to give the second command.

hope i am clear, thanx...

MSComm1
greeting! i m doing this for a project but i dunnu how to use the mscomm in vb6, and wat is mscomm1?
cos in my code

dim newcomm as MSComm
newcomm.Setting = "9600,n,8,1"
newcomm.PortOpen = true

will give me a warning saying that object or whole block not set

And is there certain setting to be adjust if i want to use MScomm in my form? pls help

Can't Receive NUL, DC1 Or DC3 Via MSComm1
I am sending serial data from a microcontroller to a PC.
The ASCII values 0 (NUL), 17 (DC1) and 19 (DC3) don't seem to be arriving at the input buffer in Visual Basic.

For example if I tell the microcontroller to send the following ASCII values:
1,0,2,17,3,19

and the VB code at the other end looks like this:
MSComm1.InputMode = comInputModeBinary
MSComm1.InputLen = 0
...
Select Case MSComm1.CommEvent
Case comEvReceive
Buffer = MSComm1.Input
For i = LBound(Buffer) To UBound(Buffer)
Debug.Print Buffer(i) & "|"

The resulting output is: 1|2|3|

Every value up to 255 arrives in the Buffer() EXCEPT 0,17 and 19.

WHY? What am I overlooking??

JoeD

Mscomm1.input
Hi! I have problem here. These are my codes. What i'm trying to do is when i give "1" (actually i'm using push button), it should be communicate. The sw1=text4.text=1 but it stil write "0". Why?

Private Sub Command4_Click()

inputsw1 = MSComm1.Input
If inputsw1 = "" Then
inputsw1 = "0"
End If

sw1 = Asc(inputsw1)
Text4.Text = sw1


If sw1 <> 1 Then

For turn = 1 To 150
MSComm1.Output = Chr$(9)
MSComm1.Output = Chr$(12)
MSComm1.Output = Chr$(6)
MSComm1.Output = Chr$(3)
Next turn

Else 'here when i push button(give "1" MSComm1.Output = Chr$(0) 'value)it shoulbe run this line but can't

End If

End Sub

Mscomm1 Is Being Stupid
righty, i open the port and that works. then i try and send data and VB returns the error: Invalid use of property.

this is the code i have used:

mscomm1.portopen = true
mscomm1.output "silly"

why doesn't it work???

Error When Using MSComm1
I have the following code: (thanks to Billsoo)


Dim intNewComm As Integer
intNewComm = 0

Do While intNewComm < 5

MSComm1.CommPort = intNewComm
MSComm1.PortOpen = True
MSComm1.Output = "test"

Sleep 100 'using the API sleep function to wait a bit
' Debug.Print MSComm1.Input

Select Case MSComm1.Input
Case "test"
MsgBox "Loopback Device found on Comm Port: " & intNewComm
strComm = intNewComm
Call ChangedSettings
Exit Do
Case Else
intNewComm = intNewComm + 1
End Select

MSComm1.PortOpen = False

Loop


I am trying to get it to test all the serial ports for a loopback device and it gives me the following error:

"comPort Invalid 8002 Invalid Port Number "

I am looping 1 - 4 and it even shows up as com 1 when it gives the error....what am I missing !?!?

Thanks again !

Mscomm1 Advice Please
Hi All

Please could someone give me some advice, i am writing a program that gets data from a digital scale using the mscomm1 control. I have set the scale to send data continuesly. So basicall what i have at the moment is when an item is put onto the scale i click on a command button and the weight is put into a textbox, the only problem i am having is that i have to push the command button 2 or 3 times before i get the correct weight. Please could someone give me some advice on this. Below is the code that i have for the command button.


Code:
Private Sub cmdGet_Click()
'Puts the full bottle weight from the scale into the full text box'
txtNew.Text = MSComm1.Input
txtNew.Text = Replace(txtNew.Text, "@", "")
txtNew.Text = Replace(txtNew.Text, "B", "")
txtNew.Text = Replace(txtNew.Text, "00", "")
End Sub


I set all the com port settings on form load which seems to work fine.

Many thanks in advance
AJ

Vb6 MSComm1 && Timers
I have an project where I received data through the MSComm1 Port every second. This data is stored in a string.
Then I have two separate Timers. One Executing (timing out) every 2 minutes and the other one Executing (timing out) every 10 Minutes. How can I send this string of Data to every timer each time they Time up?
In other words, since I am recieving data every second, how can I detect that either timer is ready to accept the String of Data?

Thanks!

Sending Hex Value From MSComm1...
Hi. I have hex commands to send from MSComm1.output. How do I do that? I want to send 0x41, 0xFE, and so on. Thanks for your help.

Sending Hex Value Out Using MSComm1...
Hi. How do I send out a hex command value through MSComm1? I usually have to resort to MSComm1.Output = "A" to send a hex 0x41, for example. But what if I needed many more commands, more than the "viewable" AscII characters? For example. If I needed to send a 0x01. This would be a SOH - Start Of Heading which does not have any characters associated with it. What is the solution. I would like to send a MSComm1.Output = 0x01.

Thank you.

Use Mscomm1 From Different Form
hay guys

I want to use mscomm1 on different forms (actually on 2 forms) which means on form1 i can do serial communication and the serial communication can be done on form2 as well.. I have tried putting mscomm1 on both form1 and form2.. When i click a button i close the port(COM1) and load form2.. Then i open the port(COM1) on form2.. I may change bk to form1 in the same way..

There is no error when i run, but after i change to another form the communication cant be continued anymore.. Pls somebody adivce me... how can i implement this (using same mscomm(COM1) on different form )... thx .. very urgent pls

phone naing

Guide Me Using MSComm1 Please
Hi all..

i got hardware where only just transmit 8 bits data. I'm using rs232 9pin, I only connect the ground and transmitter. What i'm looking for is that the code that i can use to display the 8 bits data every 5 secs in the text box when you click command button. So, i guess, in the form there will be timer, MScomm, command button and text box. Please anyone.. help me...

Mscomm1 Need To Change
hi, this code uses mscomm1 it is possible to change into a usb? im using a box with ftdichip inside... how to send this command using usb?


VB Code:
Dim arrayhex(300) As VariantDim arraynum(300) As Byte Private Sub Command1_Click()Text1.Alignment = 0Command1.Enabled = FalseMSComm1.Settings = "9600,o,8,1"If Option1.Value = True Then MSComm1.CommPort = 1If Option2.Value = True Then MSComm1.CommPort = 2MSComm1.RTSEnable = TrueMSComm1.DTREnable = FalseMSComm1.PortOpen = True Text1 = " Setting TESTMODE" Envia ("1F 00 10 7F 00 70")pause (400)Envia ("1F 00 10 15 00 06 00 04 04 01 04 00 01 18")pause (400)Envia ("1F 00 10 7F 01 71")pause (400)Envia ("1F 00 10 15 00 06 00 04 04 01 04 00 02 1B")  Text1 = "Done"      MSComm1.PortOpen = False      pause (1000)      Text1 = ""Timer2.Enabled = TrueGoTo dc:Timer1.Enabled = Trued: End Sub

MSCOMM1 Problem
Hello, I have phone logs being sent to a servers comm1 port each time a person hangs their phone up from a call.

Below are my settings for mscomm:


VB Code:
Private Sub Form_Load()    MSComm1.RThreshold = "1"    MSComm1.SThreshold = "1"    MSComm1.InputLen = "0"    MSComm1.InBufferSize = "1024"    MSComm1.OutBufferSize = "512"    MSComm1.EOFEnable = blnEOFEnable    MSComm1.RThreshold = 1    MSComm1.SThreshold = 1    MSComm1.Settings = "19200,n,8,1"End Sub


Upon MSComm1.CommEvent = comEvReceive, MSComm1.Input is set to a variable called "strBuffer", and is used in the following:


VB Code:
Private Sub InputData(strBuffer As String)Dim strData As StringIf Asc(strBuffer) = 13 Then    txtConsole.Text = txtConsole.Text & vbCrLf        MsgBox strData        MsgBox "13"ElseIf Asc(strBuffer) = 10 Then    txtConsole.Text = txtConsole.Text & vbCrLf        MsgBox strData        MsgBox "10"Else    txtConsole.Text = txtConsole.Text & strBuffer    strData = strData & strBufferEnd IfEnd Sub


My problem is as follows, each time a log is received, it is correctly placed into my textbox. It keeps putting data (sent in parts), in the same line of txtConsole.Text until Asc(strBuffer) = 13, then a line break occurs. But when my messagebox for strData (which should be setting to the same value as strBuffer) fires, nothing is in the messagebox. Can anyone see whats wrong with my code?

How To Close MSComm1 ?
I use

MSComm1.PortOpen = false

But there is error : Only useful when the port is open .

But I think the port is open because it can receive data.

MSCOMM1 Loop Or If-Then
Is it better to use an If-then type statement to fill a string with mscomm1.input ? Or is it better to use a loop statement

If then example:


VB Code:
Private Sub com_OnComm()Dim i As StringDim Data as String i = com.Input      If i = vbCr Then         text1.text = data         data = VBNullString     Else         data = data + i     End If End Sub


If using a loop is better could someone provide me with an example??


Thanks all

Mscomm1 Question
Please, I want to know when the communication from the serial port is over.
With the event comEvReceive I am handling the information but I need to know when the transmition is over.
Thanks,

Mscomm1 Error
I was given a code written in Vb 6.0 to work the bugs out of it. I am running into a problem with opening the rs232 port on my computer. The code to do this is supposed to be

Sub Inisetting()

If MSComm1.PortOpen = True Then Exit Sub
   MSComm1.CommPort = 1
   MSComm1.Settings = "9600,o,8,1"
   MSComm1.PortOpen = True
   MSComm1.Output = "B"
   MSComm1.Output = "q"
   MSComm1.InputLen = 1

End Sub

The compile error is "method or data member not found" It points me to the part following MSComm1 I.E. PortOpen or CommPort and so on.
Every Example I have seen on how to open a port does it this way. Any suggestions would be greatly appreciated.

Thanks in Advance
Jason

Mscomm1.input
Hello VbBoys,
I'm starting a comunication with an equipament via RS 232 and a serial port.
I used the component mscomm1 and the command output is working. But I can't read the input of the equipament.
I think the fail is not setup correctly the mscomm1 or not write the correctly routine for input.
My setup was:
.settings="9600,N,8,1"
.comport=1
.portopen=true
.Handshaking = comXOnXoff
.InputMode = comInputModeText
...
My routine to read the input is:
do
buffer$=mscomm1.input
loop until instr(buffer$,"OK") 'OK is the status of the equipament

If some one can help me or send me an example, I will thanks.

BarrosAS

Copyright 2005-08 www.BigResource.com, All rights reserved