MSComm Control causing an external software program to crash while communicating with it.

I am using VB 6.0 programming a MSCOMM control running under WINNT OS.  I am Using this program to interface with a external program that develops and sends a file to a solder flow machine.  This machine has three main programs that we run.  I am using a touchscreen computer and writing the code to download the program to the solder machine and also upload the program from the external software program.  When running the following code I get this error msg and the external program shuts down, if i step through the program, it works fine.

Private mnuReceive_Click()
Dim A as integer
If TypePart = 1 then
MSComm3.output = NAME?
loop while MSComm3.InBufferCount = 0
temp = MSComm3.input
temp = Left(temp,4) ' gets the name of the program from the external software
A = 0
Data_DCND(A,0) = temp ' stores the data in an array
do while a< 100
call stepTXT(A)
MSComm3.output = Step
temp = ""
temp = temp & MSComm3.input
Loop until InStr(temp, vbcrlf)
Data_DCND(A + 1,0) = temp
A = A + 1
if temp = "0019000000000000000000000000000000000000" & VbCrLf then
ProgramReceived = 1
msgbox ("Program Received")
exit sub
end if

end if
end sub

Private Sub StepTXT(A as integer)
if A <= 9 then
Step = "Step000" & A
elseif A > 9 and A < 100 then
Step = "Step00" & A
Step = "Step0" & A
end if
end sub

What could be causing my problem?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

The program at the other end is faulty if it crashes with unexpected data.
Your program is full of syntax errors. I'm surprised you can get it to run at all.

Private mnuReceive_Click()
should be
Private Sub mnuReceive_Click()

MSComm3.output = NAME?
quotes missing round string literal

loop while MSComm3.InBufferCount = 0
Missing Do
etc, etc
jfarmer20Author Commented:
Sorry about the typing errors.   I did not cut and paste the program, I retyped into the question.  There are not any syntax errors on the program.  What I have noticed is when the program is running, the external software receives multiple commands and does not see the VbCrLf.  (Example:  NAME?NAME?NAME?)
Ar you sending the vbCrLf?  I can't sse it in what you typed.
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

jfarmer20Author Commented:
I did not type in the VbCrLf on the original question, I am sending the VbCrLf along with the data.  I added a sleep function in the program between the writes and reads which helped.  The program will now run but sometimes it will not communicate with the external program.  Still maybe something about the protocol from the external software (Software is called SPA 250-400 which creates and downloads programs to a solder wave machine).  Thanks for the help you have been giving me.

Sorry, this is a VB-specific area. We do not know about particular applications. Do you have a link to the site which gives information about the protocol that they use?

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
I don't hink I was much help here. Please refund the questioner's points.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.