Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 54
Default Mscomm1 buffer problem

I have the following code that reads a Data Acquisition system. It is
suppose to put the data from CALL 1 into textbox1 and CALL 2 into
textbox2. However they are comming back reversed. I checked my
userform and I have the textboxs labeled correctly (not reversed)

When I comment out either channel it put the data in the correct
textbox.
I eventually need 5 channels. My system will not read all the
channels simultaneously so I have to loop thru each channel to get its
value.
I have tried varying a delay to see if the buffer is getting updated
too fast but I have not had luck with that approach.

I was looking for a feedback to know the buffer is complete before
outputing to the form. I have my bufferlength set to 0 so it brings it
in all at once instead of each bite.

What can I do here to correct this problem?
Thanks in advance.

BTW: Netcomm1.ocx is the free version of MSCOMM1.ocx. The only
difference is the "input" needs the "data" added.


Private Sub CommandButton21_Click() ' Stream Data into Channels

CommandButton21.Enabled = False
CommandButton23.Enabled = True

C1 = True

Do While C1 = True

Buffer1$ = ""
NETComm1.Output = "CALL 1" & Chr(13) ' retrieve reading
from Serial Device
Buffer1$ = Buffer1$ & NETComm1.InputData
TextBox1 = Application.Clean(Buffer1$)
TimedDelay (0.5)

Buffer2$ = ""
NETComm1.Output = "CALL 2" & Chr(13) ' retrieve reading
from Serial Device
Buffer2$ = Buffer2$ & NETComm1.InputData
TextBox2 = Application.Clean(Buffer2$)
TimedDelay (0.5)
Loop
End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Mscomm1 buffer problem

In the userform there is a caption and a name. the name needs be changed to
match the code. The name is the first line in the userform properties
windows and is what the code actually uses to identify the userrform. the
caption is just a text string for display puposes only. The name and the
caption can be different.

"gtslabs" wrote:

I have the following code that reads a Data Acquisition system. It is
suppose to put the data from CALL 1 into textbox1 and CALL 2 into
textbox2. However they are comming back reversed. I checked my
userform and I have the textboxs labeled correctly (not reversed)

When I comment out either channel it put the data in the correct
textbox.
I eventually need 5 channels. My system will not read all the
channels simultaneously so I have to loop thru each channel to get its
value.
I have tried varying a delay to see if the buffer is getting updated
too fast but I have not had luck with that approach.

I was looking for a feedback to know the buffer is complete before
outputing to the form. I have my bufferlength set to 0 so it brings it
in all at once instead of each bite.

What can I do here to correct this problem?
Thanks in advance.

BTW: Netcomm1.ocx is the free version of MSCOMM1.ocx. The only
difference is the "input" needs the "data" added.


Private Sub CommandButton21_Click() ' Stream Data into Channels

CommandButton21.Enabled = False
CommandButton23.Enabled = True

C1 = True

Do While C1 = True

Buffer1$ = ""
NETComm1.Output = "CALL 1" & Chr(13) ' retrieve reading
from Serial Device
Buffer1$ = Buffer1$ & NETComm1.InputData
TextBox1 = Application.Clean(Buffer1$)
TimedDelay (0.5)

Buffer2$ = ""
NETComm1.Output = "CALL 2" & Chr(13) ' retrieve reading
from Serial Device
Buffer2$ = Buffer2$ & NETComm1.InputData
TextBox2 = Application.Clean(Buffer2$)
TimedDelay (0.5)
Loop
End Sub


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 54
Default Mscomm1 buffer problem

I changed the 2 lines to send to the textbox to read:

UserForm1.TextBox1 = Application.Clean(Buffer1$)
UserForm1.TextBox2 = Application.Clean(Buffer2$)

And I still go the same error.

I am calling the code from a commmandbutton on the userform1

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Mscomm1 buffer problem

You should have two routines. One to handle each button.

Private Sub CommandButton21_Click() and
Private Sub CommandButton23_Click()

the while should be changed
from
Do While C1 = True
to
Do While C1

there also isn't any condition to exit the while loop. Don't know why you
need to loop. The sub will only get called when the button is clicked unless
you need to read the serial device multiple times.
"gtslabs" wrote:

I changed the 2 lines to send to the textbox to read:

UserForm1.TextBox1 = Application.Clean(Buffer1$)
UserForm1.TextBox2 = Application.Clean(Buffer2$)

And I still go the same error.

I am calling the code from a commmandbutton on the userform1


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Mscomm1 buffer problem

Joel,
Those two statements appear functionally equivalent to me
Do While C1 = True

to
Do While C1

what was the significance of this suggestion?

as to looping, It looks like he is starting a loop to query the comm
controls continuously. given that information I don't see where two buttons
would be needed.

to the original poster. Have you tried putting your Timedelay between
issuing the call statement and when you get the input data?

--
Regards,
Tom Ogilvy




"Joel" wrote:

You should have two routines. One to handle each button.

Private Sub CommandButton21_Click() and
Private Sub CommandButton23_Click()

the while should be changed
from
Do While C1 = True
to
Do While C1

there also isn't any condition to exit the while loop. Don't know why you
need to loop. The sub will only get called when the button is clicked unless
you need to read the serial device multiple times.
"gtslabs" wrote:

I changed the 2 lines to send to the textbox to read:

UserForm1.TextBox1 = Application.Clean(Buffer1$)
UserForm1.TextBox2 = Application.Clean(Buffer2$)

And I still go the same error.

I am calling the code from a commmandbutton on the userform1




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 54
Default Mscomm1 buffer problem

Yes, that worked Tom, thanks

The C1 was used as a public boolean variable so I can turn off the
continious loop monitor.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How can buffer the row height of my data. RSB Excel Discussion (Misc queries) 1 April 15th 08 11:35 PM
Read Keyboard Buffer ? Gary''s Student Excel Programming 2 September 7th 06 03:42 AM
Reading txt file into the buffer WannaBeExceller Excel Programming 2 February 8th 06 11:21 PM
buffer overflow Jeff Sward Excel Programming 0 January 7th 04 07:46 PM
Emptying the copy buffer justin Excel Programming 1 October 27th 03 03:03 PM


All times are GMT +1. The time now is 03:22 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"